Repository navigation
refactor: remove prefinalizer from utilityprocesswrapper and simpleurlloaderwrapper - #53358
Merged
MarshallOfSound merged 2 commits intoSep 1, 2026
Conversation
Store URLLoaderNetworkObserver in a separate allocation so its mojo receivers remain accessible while UtilityProcessWrapper is awaiting cppgc sweeping. This avoids requiring a prefinalizer to disconnect the receivers.
Route stream and network observer callbacks through a separately allocated client holding a weak reference to SimpleURLLoaderWrapper. This keeps mojo dispatch state valid during cppgc sweeping without requiring a prefinalizer.
MarshallOfSound
approved these changes
Sep 1, 2026
MarshallOfSound
merged commit Sep 1, 2026
994ea77
into
fix/chunked-upload-stream-hang
89 checks passed
|
No Release Notes |
MarshallOfSound
added a commit
that referenced
this pull request
Sep 1, 2026
* fix: settle pending upload stream reads when a net.request ends When a protocol handler reads the chunked upload body of a net.request through the stream it is handed, and the request then fails or is aborted, the handler's pending read was never settled: nothing told the JSChunkedDataPipeGetter that the request was over, so the GetSize reply the stream waits on never arrived and its SelfKeepAlive rooted it forever. Abort the getter from SimpleURLLoaderWrapper::OnComplete and Cancel so the stream's pending read rejects with the request's net error. This is also what made the cpp-heap ChunkedDataPipeReadableStream spec hang under ASan/UBSan: its handler drops the one-time protocol callback, which is only weakly referenced from C++, so the test's own GC loop could collect it and fail the request with ERR_FAILED before request.end() ran. The test now holds the callback for its duration, and a new net spec covers the abort path directly. Co-authored-by: Sam Attard <[email protected]> * fix: drop mojo receivers before cppgc sweeps a dead request wrapper ASan on CI caught a use-after-poison in mojo::ReceiverSetState::Entry:: OnDisconnect. The poison history shows cppgc's UnmarkedObjectsPoisoner poisoning a SimpleURLLoaderWrapper at the start of a sweep, i.e. after the GC found it dead but before its destructor ran; the network service's disconnect for one of the wrapper's URLLoaderNetworkServiceObserver receivers then landed on the dead object. UtilityProcessWrapper owns the same kind of ReceiverSet for a utility process's requests. Give both a cppgc pre-finalizer that drops the receivers before the sweep, the pattern ReplyChannel and the IPC renderer objects already use. Also from review: - Abort() only resets the chunked getter instead of answering GetSize with an error, which the network service DCHECKs against; consumers already treat the disconnect as the body ending with ERR_FAILED, so a handler's pending read reports the request failure rather than the abort. - A write still in flight when the request ends is rejected with ERR_ABORTED instead of never settling, and the request's internal body stream no longer re-raises that as an unhandled error. Co-authored-by: Sam Attard <[email protected]> * refactor: remove prefinalizer from utilityprocesswrapper and simpleurlloaderwrapper (#53358) * refactor: move utility process network observer off cppgc heap Store URLLoaderNetworkObserver in a separate allocation so its mojo receivers remain accessible while UtilityProcessWrapper is awaiting cppgc sweeping. This avoids requiring a prefinalizer to disconnect the receivers. * refactor: move URL loader callbacks off cppgc heap Route stream and network observer callbacks through a separately allocated client holding a weak reference to SimpleURLLoaderWrapper. This keeps mojo dispatch state valid during cppgc sweeping without requiring a prefinalizer. Co-authored-by: Robo <[email protected]> * fix: settle a chunked upload write that is in flight when the request is aborted ChunkedBodyStream dropped the pending first-chunk write callback on abort, so the caller's write callback never fired. Let it settle with the abort error instead, which is what Node.js does (ECANCELED); no 'error' event follows because the request is already destroyed by the time it lands. Co-authored-by: Sam Attard <[email protected]> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Sam Attard <[email protected]> Co-authored-by: Robo <[email protected]>
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.
Description of Change
Followup to #53341
cppgc prefinalizer should be a last resort because every registered prefinalizer must be examined during garbage collection, adding per object storage and GC overhead.
Release Notes
Notes: none