Repository navigation
Conversation
Collaborator
|
Review requested:
|
Sessions and streams are detached from JavaScript ownership: the SessionManager and the session's streams map hold the sole BaseObjectPtr references. Synchronous JavaScript callbacks made during Stream::Destroy(), Session::SendPendingData(), Session::SendDatagram() and Session::TryWritePendingDatagram() can destroy the session, dropping the last owning reference and freeing the C++ object while native code still touches it, resulting in a heap use-after-free (observed as a crash in Session::SendPendingDataScope::~SendPendingDataScope()). Pin the session with a strong BaseObjectPtr<Session> in SendPendingDataScope and in SendPendingData()/SendDatagram(), and pin the stream with a BaseObjectPtr<Stream> in Stream::Destroy(). Guard the re-entrant JavaScript call sites (StreamDataBlocked -> EmitBlocked, DatagramStatus) with is_destroyed() checks before continuing, so the send loop never dereferences a destroyed session's impl_. Signed-off-by: Matteo Collina <hello@matteocollina.com>
mcollina
force-pushed
the
quic-pin-session-stream-lifetimes
branch
from
November 24, 2026 10:45
d31e737 to
d2c4b69
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #67744 +/- ##
=======================================
Coverage 90.54% 90.55%
=======================================
Files 803 803
Lines 285094 285110 +16
Branches 55024 55024
=======================================
+ Hits 258133 258170 +37
+ Misses 17105 17088 -17
+ Partials 9856 9852 -4 🚀 New features to boost your workflow:
|
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.
QUIC sessions and streams are detached from JavaScript ownership: the
SessionManager and the session's streams map hold the sole BaseObjectPtr
references. Synchronous JavaScript callbacks issued while native code is
still using these objects (Stream::Destroy, Session::SendPendingData,
Session::SendDatagram, Session::TryWritePendingDatagram, and the
SendPendingDataScope destructor) can destroy the session, drop the last
owning reference, and free the C++ object while it is still being accessed,
causing a heap use-after-free.
Pin the session with a strong BaseObjectPtr in SendPendingDataScope
and in SendPendingData()/SendDatagram(), and pin the stream with a
BaseObjectPtr in Stream::Destroy(). Add is_destroyed() guards at the
re-entrant JavaScript call sites (StreamDataBlocked -> EmitBlocked,
DatagramStatus) so the send loop does not continue after the session has been
destroyed.