You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Process: correct a subtle runLoopSource lifetime issue
When a process is run with `run`, a monitoring thread is setup by means
of a socketpair. This socket is used to create a runloop source, which
will monitor the process for termination. `waitUntilExit` will monitor
the `isRunning` ivar which is set by the source to indicate the process
termination having been observed. We however would previously mark the
process as terminated before invalidating the runloop source to prevent
any new callouts on the source. However, the operation is multithreaded
the operation is not guaranteed to be serialized and the runloop source
may be `nil`'ed prior or during the invalidation which also releases as
the refcount is now 0. This would result in the `runloopSource` passed
to `CFRunLoopSourceInvalidate` being `nil` and breaking the contract of
the call or a UaF if the value is `nil`'ed during the execution. These
states have both been observed in practice. Reordering the `isRunning`
ivar assignment to occur after the invalidation ensures that the value
remains usable until we no longer reference it.
0 commit comments