#54191: test: collect orphaned MessagePortMain with a precise GC in the close-event spec
Merged
Created: Sep 21, 2026, 6:16:00 PM
Merged: Sep 21, 2026, 9:51:18 PM
3 comments
Target: main
Description of Change
Fixes the ipc module > MessagePort > close event > … sent to nowhere flake seen on the linux-x64-ubsan shard (e.g. #54170).
v8Util.requestGarbageCollectionForTesting()collects synchronously, so cppgc scans the native stack conservatively. Called from inside an IPC handler, the frames that just entangled the incomingMessagePortMaincan leave a stale pointer on that stack and the orphaned port survives, soclosenever fires. A heap snapshot taken at that point shows the port retained only byC++ native stack roots.- Adds
requestGarbageCollectionForTesting({ execution: 'async' }): posts a non-nestable task and collects withStackState::kNoHeapPointers, mirroringgc({ execution: 'async' }), and resolves a promise when done. - Uses it in the two specs that assert a C++ object is reclaimed after a single collection (the MessagePort test and
invoke … reply callback is dropped).
| UBSan build of the CI base commit, 1 run = 1 fresh process | sent to nowhere |
|---|---|
| before | 12/12 fail |
| new binary, old synchronous spec | 5/6 fail |
new binary + { execution: 'async' } |
20/20 pass |
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
- tests are changed or added
Release Notes
Notes: none
Backports
44-x-y
PendingWaiting for a manual backport
Semver Impact
Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron