If either of these types of servers are created, but never started, then when they are deallocated the following is thrown:
XPC API Misuse: Release of last reference on a suspended connection.
After a bunch of debugging and documentation reading I'm pretty sure what's going on is the following:
"XPC connections, like dispatch sources, are returned in a suspended state [...] connections must be resumed in order to be safely released. It is a programming error to release a suspended connection."
Both XPCAnonymousServer and XPCMachServer create listener connections as part of their initialization, but do not call xpc_connection_resume(...) on them as part of initializing
(If either of those servers are started, then resume is called and this issue is not experienced)
xpc_release is unavailable in Swift, but appears to be called by the Swift runtime (or possibly inserted at compile time?) when the listener connection's retain count reaches zero due to the runtime's builtin reference counting
When xpc_release is called on a listener connection the application/executable/test harness experiences a EXC_BAD_INSTRUCTION (SIGILL) due to the aforementioned: "XPC API Misuse: Release of last reference on a suspended connection."
Reproducing this issue with a test is trivial, just create a new test and the entire function's body should just be:
If either of these types of servers are created, but never started, then when they are deallocated the following is thrown:
After a bunch of debugging and documentation reading I'm pretty sure what's going on is the following:
XPCAnonymousServer
andXPCMachServer
create listener connections as part of their initialization, but do not callxpc_connection_resume(...)
on them as part of initializingxpc_release
is unavailable in Swift, but appears to be called by the Swift runtime (or possibly inserted at compile time?) when the listener connection's retain count reaches zero due to the runtime's builtin reference countingxpc_release
is called on a listener connection the application/executable/test harness experiences a EXC_BAD_INSTRUCTION (SIGILL) due to the aforementioned: "XPC API Misuse: Release of last reference on a suspended connection."Reproducing this issue with a test is trivial, just create a new test and the entire function's body should just be: