napperley
06/29/2021, 3:20 AMUncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: Trying to access top level value not marked as @ThreadLocal or @SharedImmutable from non-main thread
at ThrowIncorrectDereferenceException (0x28742c)
at (0x32cda1)
at Kotlin_initRuntimeIfNeeded (0x33cd7b)
at _636f6d2e636861706d616e3a626f6c742d646174612d636f6e73756d6572_kncfun78 (0x32e26c)
at MQTTClient_run (0x347173)
at (0x7fd0e85d86db)
at clone (0x7fd0e80e9a3f)
at ((nil))
napperley
06/29/2021, 3:26 AMTijl
06/29/2021, 6:29 AMTijl
06/29/2021, 6:30 AM@ThreadLocal
or @SharedImmutable
on it.
unfortunatly, even in the stdlib there is a bunch of fields without this.Tijl
06/29/2021, 6:36 AMKotlin_initRuntimeIfNeeded
can be a red herring, it can get in the stacktrace inbetween your own code, if that code is first to run in that thread, so I would try to get debug symbols for (0x32cda1)
Tijl
06/29/2021, 6:38 AMPaul Woitaschek
06/29/2021, 8:05 PMunfortunatly, even in the stdlib there is a bunch of fields without this.Where?
Tijl
06/29/2021, 8:10 PMPaul Woitaschek
06/29/2021, 9:24 PMnapperley
06/30/2021, 12:43 AMnapperley
06/30/2021, 12:52 AMprivate fun mqttMessageArrived(
@Suppress("UNUSED_PARAMETER") ctx: COpaquePointer?,
topic: CPointer<ByteVar>?,
@Suppress("UNUSED_PARAMETER") topicLength: Int,
msg: CPointer<MQTTClient_message>?
): Int {
initRuntimeIfNeeded()
return true.intValue
}
I have removed everything in the event handler body except for initRuntimeIfNeeded(), and return true.intValue, and the issue still occurs which is weird.napperley
06/30/2021, 12:54 AMnapperley
06/30/2021, 12:55 AMnapperley
06/30/2021, 3:12 AMTijl
06/30/2021, 6:55 AMnapperley
06/30/2021, 10:13 PMnapperley
06/30/2021, 10:15 PMPaul Woitaschek
07/06/2021, 3:34 AMnapperley
07/07/2021, 12:33 AM