daphillips
01/26/2023, 10:16 PM-Xdebug
in kotlin 1.8? I've been getting java.lang.VerifyError: Bad local variable type
errors whenever I turn it on in my project.
I haven't been able to create a minimal reproducible example yet, but it seems to happen around scope.launch
or channel.send
calls...ephemient
01/26/2023, 10:28 PMdaphillips
01/26/2023, 10:35 PMType top (current frame, locals[5]) is not assignable to reference type
, but at different locations depending on how I manipulate the stack. With the peculiar part being that it's always the 5th-indexed local variable...
more to investigateNorbi
01/27/2023, 1:46 PMjava.lang.VerifyError: Bad local variable type
Exception Details:
Location:
...-W5ldpIw(Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @707: iload
Reason:
Type 'java/util/concurrent/locks/Lock' (current frame, locals[9]) is not assignable to integer
Without -Xdebug
the error goes away...daphillips
01/27/2023, 10:23 PMfun main() = runBlocking {
Path("/tmp")
withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
println("hello world!")
}
}
ephemient
01/27/2023, 10:43 PMdaphillips
01/27/2023, 11:08 PMPath()
with Paths.get()
seems to fix the issue? So I wonder if it's something related to how kotlin inlines Path()
to target platforms? ¯\_(ツ)_/¯ephemient
01/28/2023, 12:36 AM<http://kotlin.io|kotlin.io>.path.Path
, this generates OK bytecode:
inline fun Path(path: String): Path = Paths.get(path)
while this generates broken bytecode:
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
@kotlin.internal.InlineOnly
inline fun Path(path: String): Path = Paths.get(path)
when used in the above reproducerimport kotlin.coroutines.*
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
@kotlin.internal.InlineOnly
inline fun f(a: Int): Int = a
fun main() {
suspend {
f(0)
suspendCoroutine<Unit> {}
}
}
daphillips
01/28/2023, 12:51 AM