Does anybody understand why this crash on X64/ARM6...
# kotlin-native
m
Does anybody understand why this crash on X64/ARM64 ?
Copy code
open class IOSSerialDispatchQueue(identifier: String) : DispatchQueue {
    private val serialQueue = dispatch_queue_create(
        "com.mirego.trikot.foundation.serial_dispatch_queue.$identifier",
        dispatch_queue_serial_t()
    )

    override fun isSerial() = true

    override fun dispatch(block: DispatchBlock) {
        freeze(block)

        dispatch_async(serialQueue, freeze {
            runQueueTask(block)
        })
    }

    private fun runQueueTask(block: DispatchBlock) {
        block()
    }
}
The crash happens in class initialization at line
dispatch_queue_create("...", dispatch_queue_serial_t())
. I can reproduce with the following swift code
let _ = IOSSerialDispatchQueue(identifier: "None")
in my AppDelegate.swift file . The crash is
EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
(Kotlin 1.4)
s
dispatch_queue_serial_t()
I don’t think this should actually work.
dispatch_queue_serial_t
is just a
typealias
for
NSObject
, so
dispatch_queue_serial_t()
is an
NSObject
. Please refer to the documentation for details on valid values for the second parameter of
dispatch_queue_create
.