dispatch_data_create() crashes with EXC_BAD_INSTRUCTION

(Daniel Eggert) #1

This code crashes for me with SwiftFoundation, but not with Darwin Foundation:

/// Turn `NSData` into `dispatch_data_t`
internal func createDispatchData(data: NSData) -> dispatch_data_t {
    let c = data.copy() as! NSData
    let info = Unmanaged<NSData>.passRetained(c)
    let destructor = {
    let q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)!
    return dispatch_data_create(c.bytes, c.length, q, destructor)

I'm not sure what to look for. The values being passed into dispatch_data_create() look sane.

Is this a red herring?