fix: move Release and delete out of BlockingCall callback to prevent SIGBUS on macOS#21629
Open
fix: move Release and delete out of BlockingCall callback to prevent SIGBUS on macOS#21629
Conversation
9221e1a to
be9b609
Compare
dbanks12
approved these changes
Mar 17, 2026
Contributor
dbanks12
left a comment
There was a problem hiding this comment.
This diff is large (needs rebase?), but the change to async_op.hpp lgtm
…SIGBUS on macOS Release() and delete were called inside the BlockingCall callback, which runs on the JS thread while BlockingCall is still blocked on the worker thread. Release() drops the TSFN refcount to 0, tearing down internal state that BlockingCall needs to unwind. delete destroys the TSFN member entirely. Both cause use-after-free when BlockingCall returns on the worker thread. macOS magazine malloc unmaps freed pages aggressively → SIGBUS. Fix: move both Release() and delete to after BlockingCall returns on the worker thread, where they can execute safely.
bbdb7f7 to
91fab20
Compare
charlielye
approved these changes
Mar 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes SIGBUS crash on macOS in
ThreadedAsyncOperation(#21138). Also targeting next via #21625.Release()anddelete opwere inside theBlockingCallcallback, which runs on the JS thread whileBlockingCallis still blocked on the worker thread.Release()tears down TSFN internals (mutex/condvar) thatBlockingCallneeds to unwind, anddeletedestroys the member entirely. macOS unmaps freed pages aggressively → SIGBUS. Linux → silent use-after-free / segfault.Fix: move both
Release()anddelete thisto afterBlockingCallreturns on the worker thread.Full post mortem with diagrams