src: stop leaking a CppHeap in CommonEnvironmentSetup - #65792
Merged
nodejs-github-bot merged 1 commit intoSep 7, 2026
Conversation
`CommonEnvironmentSetup` created a `CppHeap` for its `CreateParams` before deciding how to create the isolate, but `NewIsolate()` ignores `params->cpp_heap` and attaches a heap of its own (or the one from `IsolateSettings`). The first heap was never attached or destroyed, so every non-snapshotting setup leaked one `CppHeap`; cppgc's heap registry keeps it reachable, which is why LSAN stays quiet about it. Only create the heap on the snapshotting path, where the params go to the `SnapshotCreator` directly. Refs: nodejs#55337 Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
Collaborator
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #65792 +/- ##
==========================================
+ Coverage 89.99% 90.15% +0.15%
==========================================
Files 757 769 +12
Lines 257739 261448 +3709
Branches 48881 49661 +780
==========================================
+ Hits 231961 235715 +3754
+ Misses 16861 16749 -112
- Partials 8917 8984 +67
🚀 New features to boost your workflow:
|
jasnell
approved these changes
Sep 4, 2026
Collaborator
joyeecheung
approved these changes
Sep 7, 2026
jakecastelli
approved these changes
Sep 7, 2026
Collaborator
|
Landed in 8e4d830 |
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.
Every
CommonEnvironmentSetup::Create()andCreateFromSnapshot()leaks onev8::CppHeap: the constructor created a heap for itsCreateParamsup front, but the non-snapshotting path then callsNewIsolate(), which ignoresparams->cpp_heapand attaches its own, so the first heap was never attached or destroyed (LSAN stays quiet because cppgc's heap registry still points at it).The heap is now created only on the snapshotting path, where the params go to the
SnapshotCreatorand V8 takes ownership.Tests:
test/embeddingpasses; no new test, since detachedCppHeaps cannot be enumerated.Refs: #55337
Disclosure: the code and this description were written by Claude Code, directed and reviewed by @codebytere.