EventTarget::release: guard unsigned retainCount_ decrement and drop tautological assert#56490
Open
meta-yaohway wants to merge 2 commits intofacebook:mainfrom
Open
EventTarget::release: guard unsigned retainCount_ decrement and drop tautological assert#56490meta-yaohway wants to merge 2 commits intofacebook:mainfrom
meta-yaohway wants to merge 2 commits intofacebook:mainfrom
Conversation
…ss throwing JS dispatch Summary: `EventQueueProcessor::flushEvents` retains every `EventTarget` in the batch, then for each event calls `eventPipe_` (which dispatches into JS via `UIManagerBinding::dispatchEventToJS` and can throw `jsi::JSError`), then `eventPipeConclusion_`, and finally runs a trailing loop that calls `event.eventTarget->release(runtime)`. If either pipe call throws, stack unwinding skips the release loop, leaving `strongInstanceHandle_` (a `jsi::Value` strong reference to the JS event-target object) pinned and `retainCount_` desynchronised. This change replaces the trailing release loop with an inline `EventTargetReleaseGuard` RAII object constructed immediately after the retain pass. Its destructor releases every retained target on every exit path — normal return, `eventPipe_` throw, or `eventPipeConclusion_` throw. Behaviour-preserving on the happy path: same release ordering (after `eventPipeConclusion_`), same no-`DispatchMutex` policy for release (the `events` vector still holds the strong `shared_ptr`s), zero added allocation (the guard holds two references). Adds `EventQueueProcessorTest.releasesEventTargetsWhenDispatchThrows`: builds a processor whose `eventPipe_` unconditionally throws, dispatches one event with a real `EventTarget`, asserts the call throws, then asserts `eventTarget->getInstanceHandle(runtime).isNull()` — i.e. the strong handle was released during unwind. This test fails (returns the still-pinned object) on the pre-fix trailing-loop code. Changelog: [Internal] Differential Revision: D100280132
…tautological assert Summary: Changelog: [Internal] Reviewed By: javache Differential Revision: D100280458
|
@meta-yaohway has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100280458. |
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.
Summary: Changelog: [Internal]
Reviewed By: javache
Differential Revision: D100280458