Conversation
Collaborator
|
Review requested:
|
inoway46
marked this pull request as ready for review
September 21, 2026 07:46
inoway46
force-pushed
the
backport-65778-to-v24.x
branch
from
September 21, 2026 08:44
eea6a5e to
adbbfa8
Compare
`Realm::RunCleanup()` finalizes the cppgc-managed wrappers it tracks so that none of them touches the Realm once it is gone, but it reaches them through weak persistents, and the GC clears those as soon as it finds a wrapper dead. With lazy and concurrent sweeping the destructor can run much later, so a wrapper collected shortly before `FreeEnvironment()` and swept after it was skipped by the cleanup and kept its `realm_`: `~CppgcMixin()` then wrote `should_purge_empty_cppgc_wrappers_` into the freed Realm, and a subclass destructor calling `Finalize()` as documented would have called `Clean()` with a dangling Realm. A Worker that compiles a few `vm.Script`s, gets a full GC from external memory pressure and calls `process.exit()` is enough to hit the first case. Move the Realm pointer into the list node, which the wrapper now owns and deletes in its destructor. `CppgcWrapperList::Cleanup()` unlinks every node, finalizing the wrappers that are still alive and clearing the Realm pointer for the collected ones, which only their own destructor may still touch. `Realm::PendingCleanup()` accounts for the list so it is always drained. The purge flag, its GC epilogue callback and `PurgeEmpty()` are no longer needed, and removing them also stops the list nodes of wrappers that are alive at `FreeEnvironment()` from leaking. Refs: nodejs#56534 Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com> PR-URL: nodejs#65778 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
inoway46
force-pushed
the
backport-65778-to-v24.x
branch
from
September 21, 2026 11:51
adbbfa8 to
0659664
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v24.x-staging #66168 +/- ##
=================================================
- Coverage 90.31% 90.23% -0.08%
=================================================
Files 711 714 +3
Lines 228425 234484 +6059
Branches 43160 44625 +1465
=================================================
+ Hits 206293 211588 +5295
- Misses 14090 14473 +383
- Partials 8042 8423 +381
🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
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.
Backport of #65778 to v24.x, preserving the v24 V8 APIs.
The crash was reproduced on v24.20.0; the backported fix passed the Windows stress reproduction.
Refs: #65756 (comment)