-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Bump WebKit: assert the VM's API lock is held on HandleSet mutation #36958
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
Open
robobun
wants to merge
3
commits into
main
Choose a base branch
from
farm/5c0973f7/handleset-apilock-detector
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+109
−2
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { expect, test } from "bun:test"; | ||
| import { bunEnv, bunExe, isDebug } from "harness"; | ||
| import path from "path"; | ||
|
|
||
| // Each child deliberately mutates a strong handle owned by the main VM from a | ||
| // spawned thread that does not hold the VM's API lock. Debug builds carry | ||
| // assertions guarding exactly that (JSC::HandleSet::assertMayMutate for | ||
| // JSC::Strong, the Bun__StrongRef__* asserts for StrongRootBlock slots), so | ||
| // the child must die with the assertion's message before the mutation lands. | ||
| // | ||
| // This is the liveness check for those detectors: the previous guard for the | ||
| // #30185 cross-thread HandleSet race was a probabilistic crash workload that | ||
| // silently stopped detecting when GC scheduling changed (#35356, measured in | ||
| // #36952). If a WebKit bump or binding refactor drops the assertions, the | ||
| // child survives and this test fails instead of the coverage disappearing | ||
| // unnoticed. | ||
| // | ||
| // These crashes are intentional; keep them out of crash reporting so CI does | ||
| // not pin them on unrelated tests. | ||
| const noReportEnv = { ...bunEnv, BUN_CRASH_REPORT_URL: "", BUN_ENABLE_CRASH_REPORTING: "0" }; | ||
|
|
||
| for (const [kind, message] of [ | ||
| ["strong", "Strong handles may only be created, written, or destroyed while holding their VM's API lock"], | ||
| ["strongRef", "Bun::StrongRef handles may only be created, written, or destroyed while holding their VM's API lock"], | ||
| ] as const) { | ||
| test.if(isDebug)(`unlocked off-thread ${kind} mutation aborts with the guard's message`, async () => { | ||
| await using proc = Bun.spawn({ | ||
| cmd: [bunExe(), path.join(import.meta.dir, "strong-handle-thread-guard-fixture.js"), kind], | ||
| env: noReportEnv, | ||
| stdio: ["ignore", "pipe", "pipe"], | ||
| }); | ||
| const [stdout, stderr, exitCode] = await Promise.all([proc.stdout.text(), proc.stderr.text(), proc.exited]); | ||
|
|
||
| expect(stderr).toContain("ASSERTION FAILED"); | ||
| expect(stderr).toContain(message); | ||
| expect(stdout).not.toContain("survived"); | ||
| expect(exitCode).not.toBe(0); | ||
| }); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.