Hi everyone,
I’m creating a Swift package that uses Dispatch on OS X, but I am getting an
Illegal Instruction error after I register my block for an event. Specifically,
a UD2 instruction inside of libdispatch:
Process 16425 stopped
* thread #1: tid = 0x68d099, 0x00007fff814aa360
libdispatch.dylib`_dispatch_xref_dispose + 23, queue = 'com.apple.main-thread',
stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
frame #0: 0x00007fff814aa360 libdispatch.dylib`_dispatch_xref_dispose + 23
libdispatch.dylib`_dispatch_xref_dispose:
-> 0x7fff814aa360 <+23>: ud2
Does this look like a compiler error, or have I somehow configured my package
wrong? I haven’t used any funky compiler flags. I do know that if I set my min
version to 10.7 or 10.6 I do not get the error. This is the offending function:
public func listen(backlog: Int = 32, onConnect: (clientConnection: TCPServer)
-> ()) throws {
let ret = system_listen(fd.rawValue, Int32(backlog))
if ret != 0 {
throw Error(rawValue: errno)
}
let dispatchSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ,
UInt(fd.rawValue), 0, dispatch_get_main_queue())
// dispatch_source_cancel(dispatchSource)
// dispatch_resume(dispatchSource)
dispatch_source_set_event_handler(dispatchSource) { [fd = self.fd] in
var socketAddress = sockaddr()
var sockLen = socklen_t(SOCK_MAXADDRLEN)
let ret = system_accept(fd.rawValue, &socketAddress, &sockLen)
if ret == StandardFileDescriptor.invalid.rawValue {
fatalError()
}
let clientFileDescriptor = SocketFileDescriptor(rawValue: ret,
socketType: SocketType.stream, addressFamily: fd.addressFamily)
let clientConnection = TCPServer(loop: self.loop, fd:
clientFileDescriptor)
onConnect(clientConnection: clientConnection)
}
}
If it is a bug, where should I file it? Any help would be much appreciated!
Thanks,
Tyler
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users