trilemma-dev / SecureXPC

A simple and secure XPC framework for Swift
MIT License
75 stars 15 forks source link

Fixes a racy connection finalizer issue exposed by `testShutdownServer` #49

Closed jakaplan closed 2 years ago

jakaplan commented 2 years ago

It turns out occassionally ServerTerminationIntegrationTest's testShutdownServer would result in a segfault inside of the finalizer for the connection. I'm pretty sure the issue was that a retained count needs to be taken for the WeakConnection instance (what we don't want to do is add a retain count to the connection itself).

jakaplan commented 2 years ago

@amomchilov I basically tested this by just manually running the integration test over and over again. Before it was segfaulting roughly 20% of the time, after this change I've yet to see a segfault. That's not entirely satisfying, but seems strictly better than not addressing this issue.