Skip to content

Collect garbage without stack scanning in io-context-test - #8696

Merged
nathanwhit merged 1 commit into
mainfrom
nathanwhit/io-context-test-gc-stack
Nov 19, 2026
Merged

nathanwhit merged 1 commit into
mainfrom
nathanwhit/io-context-test-gc-stack

Conversation

@nathanwhit

Copy link
Copy Markdown
Member

Two io-context-test cases failed on Windows CI (job):

  • a promise GC collects in another request settles the wait when its request next runs
  • an await_js() whose promise GC collects in another request releases its abort watcher when its request next runs

In both, the promise survived the forced GC, so the wait stayed pending and the abort watcher was never released.

collectGarbage() used LowMemoryNotification(), which runs with StackState::kMayContainHeapPointers, so cppgc scans the native stack conservatively. A stale pointer to the Wrappable that owns the await_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() with kNoHeapPointers, as tracing-test does. That call requires --expose-gc, which can't go 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. Instead, io-context-test links a new :test-fixture-expose-gc variant.

Ran every test that depends on either fixture (--nocache_test_results): all pass except //src/workerd/tests:bench-pumpto and :bench-stream-piping, which already fail to build on main (jsg::BackingStore).

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.
@nathanwhit
nathanwhit requested review from a team as code owners November 19, 2026 22:47

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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

@nathanwhit
nathanwhit enabled auto-merge November 19, 2026 23:00
@nathanwhit
nathanwhit merged commit 3d61dfd into main Nov 19, 2026
36 of 37 checks passed
@nathanwhit
nathanwhit deleted the nathanwhit/io-context-test-gc-stack branch November 19, 2026 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants