MarshallOfSound

#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 incoming MessagePortMain can leave a stale pointer on that stack and the orphaned port survives, so close never fires. A heap snapshot taken at that point shows the port retained only by C++ native stack roots.
  • Adds requestGarbageCollectionForTesting({ execution: 'async' }): posts a non-nestable task and collects with StackState::kNoHeapPointers, mirroring gc({ 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

Release Notes

Notes: none

Backports

44-x-y
Pending
Waiting for a manual backport
45-x-y
Merged
PR Number
#54198
Merged At
Sep 21, 2026, 10:50:14 PM
Released In
Not yet
Release Date
Not yet

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