Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(swingset): don't un-expose 'gc', to stop intermittent test failures #6029

Merged
merged 1 commit into from
Aug 23, 2022

Conversation

warner
Copy link
Member

@warner warner commented Aug 22, 2022

engine-gc.js acquires the gc() function (to force garbage
collection) on Node.js by turning on the (global) --expose_gc V8
flag, then evaluating code within a new context (because the original
one might not have had --expose_gc turned on), stashing the gc
global, then uses --no-expose_gc to hide it again.

It seems that AVA's worker-based parallelism approach causes multiple
calls to this routine within the same process, sharing a V8
instance. So there's a race between one worker doing
enable/stash/disable and another. If they interleave, a "stash" might
happen while the symbol is disabled, causing a Reference Error and a
crash.

closes #6028

@warner warner added the SwingSet package: SwingSet label Aug 22, 2022
@warner warner requested a review from michaelfig August 22, 2022 21:32
@warner warner self-assigned this Aug 22, 2022
Copy link
Member

@michaelfig michaelfig left a comment

Choose a reason for hiding this comment

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

Just minor terminology ("symbol" -> "binding"), otherwise LGTM!

packages/SwingSet/src/lib-nodejs/engine-gc.js Outdated Show resolved Hide resolved
@warner warner added automerge:squash Automatically squash merge and removed automerge:squash Automatically squash merge labels Aug 22, 2022
@warner
Copy link
Member Author

warner commented Aug 23, 2022

I figured out that the CI failure was another instance of #5575 (and I have an idea on how to deal with that), so I'll just re-kick the CI.

Comment on lines 10 to 11
// we leave --expose_gc turned on, otherwise AVA's shared workers
// may race and disable it before we manage to extract the binding
Copy link
Member

@mhofman mhofman Aug 23, 2022

Choose a reason for hiding this comment

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

Should we leave a comment that it's safe since at worse it would just leave a global gc in new realms (which we don't create in non-test paths), and that would get removed in Compartments anyway.

@warner warner force-pushed the 6028-gc-not-defined branch from 10ce5d7 to 49131da Compare August 23, 2022 17:50
@warner warner added the automerge:rebase Automatically rebase updates, then merge label Aug 23, 2022
engine-gc.js acquires the `gc()` function (to force garbage
collection) on Node.js by turning on the (global) `--expose_gc` V8
flag, then evaluating code within a new context (because the original
one might not have had `--expose_gc` turned on), stashing the `gc`
global, then uses `--no-expose_gc` to hide it again.

It seems that AVA's worker-based parallelism approach causes multiple
calls to this routine within the same process, sharing a V8
instance. So there's a race between one worker doing
enable/stash/disable and another. If they interleave, a "stash" might
happen while the symbol is disabled, causing a Reference Error and a
crash.

This won't cause `gc` to be visible to new Compartments, because SES
strips out all globals that it doesn't recognize.

closes #6028
@warner warner force-pushed the 6028-gc-not-defined branch from 49131da to c4f7038 Compare August 23, 2022 19:26
@mergify mergify bot merged commit 774d090 into master Aug 23, 2022
@mergify mergify bot deleted the 6028-gc-not-defined branch August 23, 2022 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge SwingSet package: SwingSet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

intermittent ReferenceError: gc is not defined during CI
3 participants