Repository navigation
Collect garbage without stack scanning in io-context-test - #8696
Conversation
The await_js() tests that GC an unsettled promise in another request failed on Windows CI: the promise survived the collection, so the wait stayed pending and its abort watcher was never released. collectGarbage() used LowMemoryNotification(), which runs with StackState::kMayContainHeapPointers. cppgc then scans the native stack conservatively, and a stale pointer to the Wrappable that owns the reaction data keeps the reactions, and the sender in them, alive. Whether such a pointer is left there depends on how the compiler laid out the frames, so the failure appears only in some builds. Use RequestGarbageCollectionForTesting() with kNoHeapPointers, as tracing-test does. That requires --expose-gc, which can't be set on TestFixture's V8 for every test: V8 hashes non-default flags into code caches, so per-isolate-compile-cache-test would see the embedded bootstrap caches rejected. Add a :test-fixture-expose-gc variant for io-context-test instead.
There was a problem hiding this comment.
✅ Approved — No issues found: a test-only change that makes GC deterministic in io-context-test, with a separate fixture so other tests run with V8's default flags.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
📋 Code Quality: ✅ LGTM
No issues. The GC call matches the one in tracing-test. io-context-test is the only binary that links the --expose-gc fixture variant, and request-ops-test still links the default fixture. The two fixture targets share their dependencies through TEST_FIXTURE_DEPS.
📝 Documentation: ✅ LGTM
The new comments in test-fixture.c++, io-context-test.c++ and tests/BUILD.bazel describe how the code works now and follow the repository's comment guidelines.
Reviewed commit: da71fa10
Two
io-context-testcases failed on Windows CI (job):a promise GC collects in another request settles the wait when its request next runsan await_js() whose promise GC collects in another request releases its abort watcher when its request next runsIn both, the promise survived the forced GC, so the wait stayed pending and the abort watcher was never released.
collectGarbage()usedLowMemoryNotification(), which runs withStackState::kMayContainHeapPointers, so cppgc scans the native stack conservatively. A stale pointer to the Wrappable that owns theawait_js()reaction data keeps the reactions, and the sender in them, alive. Whether one is left there depends on how the compiler laid out the frames, so the failure appears only in some builds.This change uses
RequestGarbageCollectionForTesting()withkNoHeapPointers, astracing-testdoes. That call requires--expose-gc, which can't go on TestFixture's V8 for every test: V8 hashes non-default flags into code caches, soper-isolate-compile-cache-testwould see the embedded bootstrap caches rejected. Instead,io-context-testlinks a new:test-fixture-expose-gcvariant.Ran every test that depends on either fixture (
--nocache_test_results): all pass except//src/workerd/tests:bench-pumptoand:bench-stream-piping, which already fail to build on main (jsg::BackingStore).