Skip to content

Bump WebKit: keep the locals of a using block's synthesized catch alive in optimized code - #37941

Closed
robobun wants to merge 2 commits into
mainfrom
farm/a3a8c180/dfg-live-catch-nested-handler
Closed

robobun wants to merge 2 commits into
mainfrom
farm/a3a8c180/dfg-live-catch-nested-handler

Conversation

@robobun

@robobun robobun commented Aug 12, 2026 •

Copy link
Copy Markdown
Collaborator

Found by fuzzing. Fingerprint: DFGOSRAvailabilityAnalysisPhase.cpp(198).

Problem

Reduced fuzzer input, run through indirect eval (that is how the REPRL harness evaluates scripts; a plain function with a using block hits the same thing once it reaches the FTL, see the second fixture):

const resource = { [Symbol.dispose]() {} };
for (using r of [resource]) {
  try { r(); } catch (e) {}
}
for (let i = 0; i < 2000000; ++i) {}

Debug/ASAN builds abort when the FTL compiles it:

DFG ASSERTION FAILED: Live bytecode local not available: operand = loc21, availabilityMap = {...}, origin = bc#188
vendor/WebKit/Source/JavaScriptCore/dfg/DFGOSRAvailabilityAnalysisPhase.cpp(198) : ...::validateNode(Node *, LocalOSRAvailabilityCalculator &)

loc21 is the hasError ("the body threw") flag of the disposal code the bytecode generator emits for using. Release builds do not abort, they miscompile: once a function containing a using block is optimized (the DFG tier is enough; the dispose call just has to remain a real call instead of being inlined), a dispose method that throws after the body also threw comes out as the dispose method's plain Error instead of a SuppressedError holding both errors, so the body's exception is silently dropped. On a release build of the unfixed engine (the phase in question is identical from the build I used through main's current pin and WebKit main):

$ bun test/js/bun/jsc-stress/fixtures/using-dispose-throw-after-body-throw-in-jit.js
error: Expected true but got false          # error instanceof SuppressedError
$ BUN_JSC_useJIT=0 bun <same file>           # interpreter: passes

Cause

DFG's LiveCatchVariablePreservationPhase keeps the locals a catch handler reads alive by inserting Flushes: in front of SetLocals inside a try range, and whenever a block's nodes cross from one handler's range into a different one (plus at the end of the block). The handler lookup it uses to detect "the handler changed" also overwrote its cached live-at-catch set with the liveness of the handler it had just found, before the flush for the handler being left was emitted, so a transition straight from one handler into another flushed the wrong handler's locals. Plain try/catch never crosses handlers inside a block because TryNode emits its jump over the catch block inside the try range. The using disposal code ends the synthesized catch's range right after the dispose call, at a label, so the block ends there as well and its terminal carries the origin of the next bytecode, which belongs to the enclosing handler (the for-of's synthesized finally here, the user's try/catch in the function case). hasError is only read by that synthesized catch, so with the flush missing nothing keeps it alive across the merge where it is either false or true; it is unavailable at the dispose call's exception exit, the exit restores it as undefined, and the catch treats that as "no pending error".

Fix

oven-sh/WebKit#417: flush for the handler being left first, then compute the liveness of the handler being entered. That PR is rebased onto WebKit cf1b36ec, which is exactly what main pins today (none of the upstream merges in #39371, #40276, #40681, #41332 and #42319 nor the fork commits in between touch this phase), so its preview build (autobuild-preview-pr-417-db6d1d70, the pin in this PR) is main's engine plus that one change. The pin should move to the final autobuild-<sha> once #417 lands.

Fixtures in test/js/bun/jsc-stress: for-using-dispose-call-live-catch-locals-ftl-validation.js is the first fuzzer shape (eval, dispose call not inlined) and using-inlined-dispose-live-catch-locals-ftl-validation.js is a small deterministic version of a second fuzzer input that hit the same assertion with the dispose method inlined into the call and the function reached through recursion; both run with --validateGraph=1, so they fail on release builds of the unfixed engine too. using-dispose-throw-after-body-throw-in-jit.js checks the SuppressedError behaviour once the function is optimized. The first and third of these are also in the WebKit PR as stress tests.

Verification

  • Fail before: all three fixtures hit the assertion above on the jsc shell shipped in the 0cbb4a19 debug-asan prebuilt (main pinned that when the evidence was gathered) and on the shell from today's pin cf1b36ec (loc12 in the function shapes, loc21 in the eval shape), the two validation fixtures also fail through the harness with USE_SYSTEM_BUN=1, and the behaviour fixture returns the wrong result on a release build of the unfixed engine. The second fuzzer input itself asserts on the unfixed engine within its first FTL compile.
  • Pass after: bun bd against the preview tarball, on this branch rebased onto current main: all three fixtures pass, jsc-stress.test.ts is 117/117 before the third fixture was added, and both fuzzer inputs no longer assert (the second one completes the FTL compile that used to fail; the input itself then runs for minutes even on a release build because it recurses to stack overflow from every level of another recursion). The preview's own jsc shell passes the fixtures as well. (Before the rebase, the earlier preview also passed test/js/web/explicit-resource-management.test.ts, test/js/bun/test/mock-disposable.test.ts, test/js/bun/resolve/lower-using-bun-target.test.ts, test/js/bun/jsc/bun-jsc.test.ts and test/js/node/async_hooks.)
  • The SuppressedError scenario matches the interpreter at both the DFG and FTL tiers with the fix.

Rebased onto main eighteen times as the WebKit pin moved underneath (the upstream merge in #39371, then #39614, #39829, #35343, #40201, the upstream merge in #40276, #40417, #40507, #40570, #40270, #40643, the upstream merge in #40681, #40767, #40816, the group #41297, #41324, the upstream merge in #41332, #41378 and #41407, and then #42002 with the upstream merge in #42319); each time the only conflict was the WEBKIT_VERSION line, resolved to the preview built on top of the new pin. Latest: preview db6d1d70 on cf1b36ec, jsc-stress 119/119 with it, and the three fixtures still fail on the cf1b36ec shell.


[policy-decision:webkit] gate passed · iteration 9 · 5 files touched

passes on PR (with fix)
Test-only change.

Debug/ASAN (expected pass):
$ bun bd test 'test/js/bun/jsc-stress/jsc-stress.test.ts'
$ BUN_DEBUG_QUIET_LOGS=1 bun scripts/build.ts --profile=debug --quiet test test/js/bun/jsc-stress/jsc-stress.test.ts
bun test v1.4.3 (4ff919377)

test/js/bun/jsc-stress/jsc-stress.test.ts:
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-arithsqrt.js [369.73ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-arithsin.js [438.09ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-string-equality.js [385.46ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-arithcos.js [429.01ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-arithtan.js [435.63ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-string-ident-equality.js [350.34ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-string-strict-equality.js [417.94ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-library-substring.js [434.36ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-regexp-exec.js [472.21ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-regexp-test.js [451.95ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-getmyargumentslength.js [368.62ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-getmyargumentslength-inline.js [327.79ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-get-my-argument-by-val-inlined.js [572.15ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-get-my-argument-by-val.js [641.68ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-call-exception.js [443.33ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-call-exception-no-catch.js [549.22ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-get-my-argument-by-val-inlined-and-not-inlined.js [848.85ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-call-varargs-exception.js [407.73ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) > ftl-try-catch-getter-throw.js [611.24ms]
(pass) JSC JIT Stress Tests > JS (Baseline/DFG/FTL) 
... (truncated)
Exit: 0
diff hotspot
scripts/build/deps/webkit.ts                       |  2 +-
 ...ispose-call-live-catch-locals-ftl-validation.js | 18 ++++++++
 .../using-dispose-throw-after-body-throw-in-jit.js | 54 ++++++++++++++++++++++
 ...ned-dispose-live-catch-locals-ftl-validation.js | 28 +++++++++++
 test/js/bun/jsc-stress/jsc-stress.test.ts          |  4 ++
 5 files changed, 105 insertions(+), 1 deletion(-)

gate history · 20 passed · 0 rejected · iteration 9

evidence per changed file
file                                                      reads  edits  tests
scripts/build/deps/webkit.ts                                 20     19     49
…-using-dispose-call-live-catch-locals-ftl-validation.js      0      1     41
…fixtures/using-dispose-throw-after-body-throw-in-jit.js      0      1     40
…ing-inlined-dispose-live-catch-locals-ftl-validation.js      1      1     41
test/js/bun/jsc-stress/jsc-stress.test.ts                     2      3     40

@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@robobun, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 56 seconds

Limit details: You’ve used all 5 included reviews currently available under your plan.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: f7c5a61b-bf29-4b7a-9980-7f9171bd0122

📥 Commits

Reviewing files that changed from the base of the PR and between 8326d1b and 61a54bd.

📒 Files selected for processing (4)
  • scripts/build/deps/webkit.ts
  • test/js/bun/jsc-stress/fixtures/for-using-dispose-call-live-catch-locals-ftl-validation.js
  • test/js/bun/jsc-stress/fixtures/using-dispose-throw-after-body-throw-in-jit.js
  • test/js/bun/jsc-stress/jsc-stress.test.ts

Comment @coderabbitai help to get the list of available commands.

@robobun

robobun commented Aug 12, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 9:59 AM PT - Sep 11th, 2026

❌ @robobun, your commit eaf28d4 has 1 failures in Build #114339 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 37941

That installs a local version of the PR into your bun-37941 executable, so you can run:

bun-37941 --bun

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I reviewed this PR and didn't find any bugs. The Bun-side diff is small and the two new stress fixtures look correct (the requireOptions directive is parsed by the existing harness, and the SuppressedError assertions are exact). That said, this pins WebKit to a preview build of an unmerged PR and pulls in everything between the old pin and current WebKit main (including oven-sh/WebKit#410) — a maintainer should sign off on shipping against a preview tag and on the wider engine bump.

Extended reasoning...

Overview

This PR bumps WEBKIT_VERSION in scripts/build/deps/webkit.ts from a commit sha to autobuild-preview-pr-417-fbb76610, a preview build of oven-sh/WebKit#417 that fixes a DFG LiveCatchVariablePreservationPhase bug affecting using disposal in optimized code. It also adds two JSC stress fixtures (the fuzzer-shaped validation case and a behavioural SuppressedError check) and wires them into jsc-stress.test.ts.

Security risks

None identified. The change is a dependency version bump plus test fixtures; no auth, crypto, or input-handling code is touched in this repo.

Level of scrutiny

High. Although the local diff is tiny, the effective change is a new JavaScriptCore binary for every platform. The preview build is cut from current WebKit main, so it carries not only the targeted fix but everything between the previous pin (7b763944…) and main — the description calls out oven-sh/WebKit#410 explicitly. Pinning to a preview tag of an unmerged upstream PR (with the description noting the pin "should move to the final autobuild-<sha> once it lands") is a release-process decision that a maintainer should confirm rather than an automated reviewer.

Other factors

  • The fixtures follow the existing jsc-stress conventions: // @bun header, //@ requireOptions(...) directives that parseJSCFlags already handles, and self-checking via shouldBe / non-zero exit on failure. --validateGraph=1 on the FTL fixture makes it fail on release builds of the unfixed engine, and the behavioural fixture asserts the exact SuppressedError shape.
  • Verified that prebuiltUrl/prebuiltDestDir in webkit.ts already handle autobuild--prefixed version strings, so the tag form of the pin resolves to the correct release URL and cache key without further changes.
  • The description's verification (fixtures fail under USE_SYSTEM_BUN=1, pass on the preview build, related ERM/async_hooks suites pass) is thorough, but CI on the actual preview tarball is what proves the wider bump is safe across platforms — that's the part a human should look at before merging.

@robobun

robobun commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

On the pin: the preview tag is only there so CI can exercise the fix before oven-sh/WebKit#417 lands; once it merges this should be re-pointed at the merged main sha, as with previous bumps of this kind. The engine content between the current pin (7b763944) and the preview is #417 itself plus oven-sh/WebKit#410 (InternalFieldTuple cast by JSType); the remaining commits in that range (#411 to #414) only change how the prebuilts are built (line tables only for the -lto variants, extra freebsd/android variants). Any bump that picks up #417 necessarily carries those too.

What the preview tarball has shown so far: locally the debug-asan tarball builds and passes jsc-stress (117/117), the explicit resource management, mock-disposable, bun-jsc and async_hooks suites (the last one covers the #410 cast path). The one failure in build 93631 was the x64-musl build step getting a 404 for bun-webkit-linux-amd64-musl-lto.tar.gz: the preview release's last asset upload had stalled, so that lane started before the asset existed. The WebKit release job has been rerun and is re-uploading the assets; I will retrigger CI here once the release is complete.

@robobun

robobun commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

The preview release is complete now (all 42 tarballs uploaded, including the musl-lto one that 404'd in build 93631), so CI has been retriggered: https://buildkite.com/bun/bun/builds/93640. No code changes since the review above; the new commit is empty.

@robobun

robobun commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

Status: build 93640's only failure is the linux x64 build-bun step, and it failed fetching the lolhtml source tarball (github.com archive download, "fetch failed" after 5 retries), not anything in this change; the preview WebKit tarball itself downloaded and extracted fine on that agent, and the other platforms' lanes are still running. That step just needs a retry. I am not going to push another empty commit for it; whoever picks this up can retry the step in Buildkite, and I will follow up on anything it turns up.

Unchanged from the description: with the preview tarball locally, both new fixtures pass, jsc-stress is 117/117, and the original fuzzer input no longer asserts; both fixtures fail on the engine without oven-sh/WebKit#417.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I reviewed this PR and didn't find any bugs in the diff itself. Because it bumps the WebKit/JavaScriptCore pin — and to a preview tag that the description says should be re-pointed at the merged autobuild-<sha> once oven-sh/WebKit#417 lands — a human should sign off on the engine bump and confirm the final pin before merge.

What was reviewed:

  • prebuiltUrl/prebuiltDestDir handle the autobuild--prefixed version string correctly (no double prefix; cache key uses the full tag).
  • The two new fixtures use //@ requireOptions(...), which parseJSCFlags already handles, and are wired into the jsFixtures list.
  • The behavioural fixture asserts SuppressedError with both .error and .suppressed messages after warming the JIT; the validation fixture relies on --validateGraph=1 so it fails on release builds too.
Extended reasoning...

Overview

This PR changes the WEBKIT_VERSION constant in scripts/build/deps/webkit.ts from the SHA 7b763944… to a preview tag autobuild-preview-pr-417-fbb76610, and adds two JSC stress-test fixtures (plus registers them in jsc-stress.test.ts). The actual code fix lives in oven-sh/WebKit#417; this PR is the Bun-side pin bump and regression coverage.

Security risks

None introduced by the diff. The bump pulls a prebuilt tarball from oven-sh/WebKit's own GitHub releases, same mechanism as before. No new user-facing surface, parsing, or auth paths are touched.

Level of scrutiny

High. Although the textual diff is tiny, changing the JavaScriptCore pin swaps out the JS engine for every code path in Bun. The bump also carries oven-sh/WebKit#410 and build-only changes #411–#414 in addition to the targeted #417 fix. Engine bumps are exactly the kind of change where a maintainer should confirm CI is fully green across all lanes and decide whether to land on the preview tag or wait for the merged SHA.

Other factors

  • The PR description and the follow-up comment both state the preview pin is temporary and should move to the final autobuild-<sha> once #417 merges — that's a pending action a human needs to track.
  • The prior CI run (#93631) had a lane fail on a 404 for a not-yet-uploaded preview asset; the current build (#93640) was retriggered after re-uploading. A human should verify it went green.
  • The test additions themselves look correct and follow the existing jsc-stress fixture conventions (//@ requireOptions, shouldBe helper, megamorphic call-site trick to prevent inlining). No issues found there.
  • No prior review comments from me on this PR.

@robobun

robobun commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

Nothing new to change from this review; the pin handling and the CI state are covered in the two comments above. For the record on the "verify it went green" point: in build 93640 the only failure is still the linux x64 build step (lolhtml source tarball download), which blocks the 41 x64 test lanes behind it; everything else is proceeding against the preview tarball, 113 jobs passed so far, including test lanes on the x64-asan (assert-enabled engine), alpine and windows builds. The handful of yellow entries so far are timing and GC sensitive tests that passed on retry or alone (test-fs-read-stream-pos, inspect-error-leak, sourcetextmodule-leak, napi GC condition, test-error-code-done-callback), none of them near exception handling or disposal. The x64 build step still just needs a retry in Buildkite.

@robobun
robobun force-pushed the farm/a3a8c180/dfg-live-catch-nested-handler branch from ae6e00a to 61a54bd Compare August 16, 2026 19:48
@robobun

robobun commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto current main. The WebKit pin had moved five times underneath this branch, so the only conflict was the WEBKIT_VERSION line. oven-sh/WebKit#417 is now rebased onto 0cbb4a19 (main's current pin) and this branch pins its new preview, autobuild-preview-pr-417-bc08a6e1, so the engine delta against main is just that one change; the earlier note about the preview also carrying #410 no longer applies. The empty retrigger commit is gone, the fixtures are unchanged.

Re-verified on the rebased branch: both fixtures still assert on the jsc shell from main's current 0cbb4a19 debug-asan prebuilt, and with the new preview bun bd passes both of them and the rest of jsc-stress (117/117), and the original fuzzer input no longer asserts. Description updated accordingly.

Comment thread scripts/build/deps/webkit.ts Outdated
* From https://github.com/oven-sh/WebKit releases.
*/
export const WEBKIT_VERSION = "0cbb4a194653231955187f9d8a2990d4b4a55266";
export const WEBKIT_VERSION = "autobuild-preview-pr-417-bc08a6e1";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 WEBKIT_VERSION is pinned to autobuild-preview-pr-417-bc08a6e1, a preview tag for the unmerged oven-sh/WebKit#417. Per the repo's Dependencies & vendoring rules ("Never merge a pin to an ephemeral artifact (preview tags, unmerged-PR builds)"), this needs to be re-pointed at the merged main commit's autobuild-<sha> — with all 42 platform×flavor tarballs verified present — before this PR lands. The PR description already notes this; flagging so it isn't merged as-is.

Extended reasoning...

What the bug is

scripts/build/deps/webkit.ts:6 sets WEBKIT_VERSION = "autobuild-preview-pr-417-bc08a6e1". This is a preview-build tag published by oven-sh/WebKit's CI for the not-yet-merged PR oven-sh/WebKit#417, not a release tag for a commit on WebKit main.

The repo's own dependency rules in .claude/docs/landing-prs.md:47 (Dependencies & vendoring, referenced from REVIEW.md) state explicitly:

Version bumps are repo-wide, verified operations. Never merge a pin to an ephemeral artifact (preview tags, unmerged-PR builds) — swap to the merged upstream SHA and verify prebuilt artifacts exist for every platform × flavor before merge.

An autobuild-preview-pr-* tag is precisely the "preview tags, unmerged-PR builds" case that rule prohibits merging.

The code path that triggers it

prebuiltUrl() in the same file constructs the download URL from cfg.webkitVersion:

const tag = version.startsWith("autobuild-") ? version : `autobuild-${version}`;
return `https://github.com/oven-sh/WebKit/releases/download/${tag}/${name}.tar.gz`;

So every fresh build with cfg.webkit === "prebuilt" (the default for CI and most local builds) fetches from https://github.com/oven-sh/WebKit/releases/download/autobuild-preview-pr-417-bc08a6e1/bun-webkit-<os>-<arch><suffix>.tar.gz. Preview releases are transient by convention — once oven-sh/WebKit#417 merges and gets its own autobuild-<merged-sha> release, the preview release can be (and typically is) cleaned up. At that point every fresh build 404s on the WebKit tarball, and bun bd / CI's build-bun step fails before compilation even starts.

Why nothing prevents it

There is no fallback in source.ts's prebuilt fetch — a 404 on the tarball is a hard build failure (the timeline already shows one lane 404ing on a not-yet-uploaded asset in build 93631). prebuiltDestDir() caches by version string, so machines that already have webkit-preview-pr-417-bc08a6e1<suffix> extracted keep working, which masks the problem locally but leaves every fresh checkout, new CI runner, and cache-cleared machine broken.

Step-by-step proof

  1. This PR merges with WEBKIT_VERSION = "autobuild-preview-pr-417-bc08a6e1".
  2. DFG: LiveCatchVariablePreservationPhase flushed the wrong handler's locals when one try range leads directly into another WebKit#417 merges to main; CI publishes autobuild-<merged-sha> with the same 42 tarballs.
  3. The now-redundant autobuild-preview-pr-417-bc08a6e1 GitHub release is deleted (standard practice for preview tags).
  4. A developer clones bun fresh and runs bun bd, or a CI runner starts with an empty cache.
  5. prebuiltUrl() returns .../autobuild-preview-pr-417-bc08a6e1/bun-webkit-linux-amd64-lto.tar.gz → 404.
  6. Build fails at the "fetch WebKit" step. Every platform × flavor is affected.

Impact

Merging as-is puts main one preview-release deletion away from being unbuildable from a clean checkout. The author has already acknowledged this in both the PR description ("the pin should move to the final autobuild-<sha> once it lands on WebKit main") and the timeline ("once it merges this should be re-pointed at the merged main sha"), so this is not a disagreement about the fix — it is the repo-mandated gate that must be satisfied before merge.

How to fix

Wait for oven-sh/WebKit#417 to land on main, then replace this line with the merged commit's 40-hex SHA (e.g. export const WEBKIT_VERSION = "<merged-sha>";) and confirm all 42 tarballs (os × arch × {musl,android,freebsd} × {debug,lto,asan}) exist under the corresponding autobuild-<sha> release before merging this PR.

@robobun
robobun marked this pull request as draft August 16, 2026 20:04
@robobun

robobun commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator Author

Agreed, and that matches the plan in the description: the preview pin exists so CI can exercise the fix, it must not land. To make that explicit I have converted this PR to a draft. Once oven-sh/WebKit#417 merges I will re-point WEBKIT_VERSION at the merged commit's autobuild- release, check that all 42 tarballs are present in it (the same list the preview release has), and mark the PR ready. The version only lives in scripts/build/deps/webkit.ts on this branch (git grep finds no other copy of the current pin), so that swap is the one line.

@robobun

robobun commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator Author

A second fuzzer input landed on the same fingerprint (same phase, same hasError local, loc20 this time). Its shape differs in two ways worth recording: the dispose method is inlined into the dispose call (it is trivial, so inlining does not split the block the way it did in the case I had looked at earlier), and the function gets hot through recursion rather than a loop. It asserts on the unfixed engine during the first FTL compile of the function; with the preview engine that compile succeeds and nothing asserts (the input itself then keeps running for minutes because it recurses to stack overflow from every level of a second recursion, so it is not usable as a test as is).

Pushed c507330 with a small deterministic version of that shape as a third fixture, using-inlined-dispose-live-catch-locals-ftl-validation.js (2s on a debug build; the dump confirms the dispose closure is inlined at the call). It asserts on the jsc shell from main's current 0cbb4a19 prebuilt, fails through the harness with USE_SYSTEM_BUN=1, and passes with bun bd test. No engine change needed, so oven-sh/WebKit#417 and the pin are untouched; description updated.

@robobun
robobun force-pushed the farm/a3a8c180/dfg-live-catch-nested-handler branch from c507330 to 298e421 Compare August 17, 2026 00:52
@robobun

robobun commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased again: main moved its pin to c6cfe90c (#39368), so the only conflict was the WEBKIT_VERSION line once more. oven-sh/WebKit#417 is now rebased onto c6cfe90c and this branch pins its new preview, autobuild-preview-pr-417-9984a386 (all 42 tarballs present), so the engine delta against main is still just that one change. With it, bun bd passes jsc-stress 118/118 (including the three fixtures here) plus the explicit resource management, mock-disposable and bun-jsc suites. Still a draft until #417 lands and the pin can move to the merged sha.

@robobun

robobun commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

A third fuzzer input came in on the same fingerprint. It is the eval shape again:

const v3 = { [Symbol.dispose]() {} };
for (using v5 of [v3]) {
    try { SharedArrayBuffer.call(); } catch (e) {}
}
let v12 = new Int8Array(51)[44];
v12++;
while (v12) {}   // never ends; this is what tiers the eval code up to the FTL

That is the shape for-using-dispose-call-live-catch-locals-ftl-validation.js already covers (the first input had r() in the try block and a bounded loop after it). The local that goes missing is the same synthesized hasError temporary of the dispose handler (loc24 with a plain indirect-eval wrapper, loc74 under the fuzzer's own prelude). Checked it against the debug-asan prebuilts: on main's pin (c6cfe90c) the jsc shell asserts in the FTL compile of <eval> exactly as reported, and on the preview pinned here that compile completes (Optimized <eval> ... using FTL with FTL) and the script then just sits in its loop until killed. The fuzzing build of main still asserts on it as well. So there is nothing to add on this branch for it.

CI for the rebased head (298e421) passed: build 99684, 179/179. Still a draft until oven-sh/WebKit#417 lands and the pin can move to the merged sha.

@robobun

robobun commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator Author

Main moved its pin to eeab0404 (#39371, the upstream merge), so the WEBKIT_VERSION line conflicts again. The bug is still there in that engine: all three fixtures assert on the jsc shell from the eeab0404 debug-asan prebuilt, and the phase itself did not change in the upstream range (the file is byte-identical between c6cfe90c and eeab0404), so oven-sh/WebKit#417 is still needed. It is now rebased onto eeab0404 (same patch, head ece09c13) and its preview build is running. This branch is rebased locally onto current main with the pin pointing at that preview; I will push it once the preview release has all of its tarballs, so CI does not run against a half-uploaded release like it did in build 93631.

@robobun
robobun force-pushed the farm/a3a8c180/dfg-live-catch-nested-handler branch from 298e421 to db1e4fe Compare August 18, 2026 06:48
@robobun

robobun commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed the rebase (db1e4fe). The preview for the rebased oven-sh/WebKit#417 is autobuild-preview-pr-417-ece09c13, built on eeab0404, and all 42 tarballs are in the release (one of its runner-side builds and then the last asset upload needed a rerun, which is why this took a while). This branch is still the same two commits, only the pin line changed in the conflict resolution. With that preview, bun bd passes jsc-stress 118/118 (the three fixtures included) plus the explicit resource management, mock-disposable and bun-jsc suites; the same three fixtures assert on the eeab0404 shell and fail through the harness with the system bun. Description updated. Still a draft until #417 merges and the pin can move to the merged sha.

@robobun

robobun commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator Author

Main's pin moved again, to 0f966e81 (#39614), so the WEBKIT_VERSION line conflicts once more. The fix is still needed there: the three fixtures assert on the jsc shell from the 0f966e81 debug-asan prebuilt (loc12, loc21, loc12 as before), and none of the four fork commits between eeab0404 and 0f966e81 touch the phase or the stress tests. oven-sh/WebKit#417 is rebased onto 0f966e81 (same patch, head ee07b022) and its preview build is running. This branch is rebased locally with the pin pointing at that preview; I will push once the release has all 42 tarballs.

@robobun
robobun force-pushed the farm/a3a8c180/dfg-live-catch-nested-handler branch from db1e4fe to bf2eecb Compare August 19, 2026 11:51
@robobun

robobun commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed the rebase (bf2eecb). The pin is now autobuild-preview-pr-417-ee07b022, which is oven-sh/WebKit#417 rebased onto 0f966e81 (main's current pin); its release has the same 42 tarballs as main's own 0f966e81 release. The preview took a few reruns to get through, the fork's preview builds were failing for every branch this morning during the Docker image setup (apt mirror and LLVM install, see oven-sh/WebKit#473), including two runs dispatched on the fork's main itself, so that was not related to this patch. The branch is still the same two commits; only the pin line changed in the conflict resolution. With this preview, bun bd passes jsc-stress 118/118 plus the explicit resource management, mock-disposable and bun-jsc suites, and the three fixtures still assert on the 0f966e81 shell. Description updated. Still a draft until #417 merges.

@robobun

robobun commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

Main's pin moved to b7f217b4 (#39829), so the WEBKIT_VERSION line conflicts again. Still needed there: the three fixtures assert on the jsc shell from the b7f217b4 debug-asan prebuilt (loc12, loc21, loc12), and the one fork commit since 0f966e81 only touches the FTL FFI lowering. oven-sh/WebKit#417 is rebased onto b7f217b4 (same patch, head 59fa7dae) and its preview build is queued. This branch is rebased locally with the pin pointing at that preview; I will push once the release has all 42 tarballs.

@robobun
robobun force-pushed the farm/a3a8c180/dfg-live-catch-nested-handler branch from bf2eecb to 9e4f46e Compare August 21, 2026 03:35
@robobun

robobun commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed the rebase (9e4f46e). The pin is now autobuild-preview-pr-417-59fa7dae, which is oven-sh/WebKit#417 rebased onto b7f217b4 (main's current pin); its release has the same 42 tarballs as main's own b7f217b4 release. The preview needed four attempts: the fork's image setup step is still flaky (oven-sh/WebKit#473 is still open), and with fail-fast one early failure cancels the rest of the group, so each attempt either gets all of the remaining jobs through or none of them. The branch is still the same two commits, only the pin line changed in the conflict resolution. With this preview, bun bd passes jsc-stress 119/119 (main added a fixture since the last round) plus the explicit resource management, mock-disposable and bun-jsc suites, and the three fixtures still assert on the b7f217b4 shell. Description updated. Still a draft until #417 merges.

@robobun

robobun commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator Author

A fourth fuzzer input landed on this fingerprint (found on cfa9f8e, which pins 0f966e81). It is the same eval shape as the first and third ones, for (using v of [resource]) { try { v(v, v, v, v, v); } catch (e) {} } followed by an endless loop, so it is the case for-using-dispose-call-live-catch-locals-ftl-validation.js covers. Checked against the current prebuilts: the b7f217b4 shell (main's pin today) and the fuzzing build of main assert in the FTL compile of <eval> on it (loc22 here, loc36 in the unreduced program the report shows), and on the 59fa7dae preview pinned here that compile completes (Optimized <eval> ... using FTL) and the script just sits in its loop until killed. Nothing to change on this branch. Build 102197 on the current head passed 179/179; still a draft until oven-sh/WebKit#417 lands.

@robobun

robobun commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator Author

Main's pin moved to aea1f010 (#35343, the Buffer accessor intrinsics via oven-sh/WebKit#330), so the WEBKIT_VERSION line conflicts again. Still needed there: the three fixtures assert on the jsc shell from the aea1f010 debug-asan prebuilt (loc12, loc21, loc12), and none of the fork commits since b7f217b4 touch the phase. oven-sh/WebKit#417 is rebased onto aea1f010 (same patch, head 191bbb7d) and its preview build is queued. This branch is rebased locally with the pin pointing at that preview; I will push once the release has all 42 tarballs.

@robobun

robobun commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

No conflict at the moment: the head pushed above (01ab140) sits directly on current main (65362b5, pin 72597399), GitHub reports the PR as mergeable, and a dry-run merge is clean. The conflict notice referred to the state before that push. CI for the new head is running as build 106966.

@robobun

robobun commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator Author

Main's pin moved to 0bb01ed5 (#40643), which also brings in the fork's Windows arm64 CI fix, so the WEBKIT_VERSION line conflicts again. Still needed there: the three fixtures assert on the jsc shell from the 0bb01ed5 debug-asan prebuilt (loc12, loc21, loc12); the fork commits since 72597399 are module loader work and the CI fix, nothing in the DFG. oven-sh/WebKit#417 is rebased onto 0bb01ed5 as a single commit again (head 79dfb46e, the stacked CI copy is gone) and its preview build is queued. This branch is rebased locally with the pin pointing at that preview; I will push once the release has all 42 tarballs.

@robobun
robobun force-pushed the farm/a3a8c180/dfg-live-catch-nested-handler branch from 01ab140 to 2a24aa6 Compare August 28, 2026 01:21
@robobun

robobun commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed the rebase (2a24aa6). The pin is now autobuild-preview-pr-417-79dfb46e, which is oven-sh/WebKit#417 rebased onto 0bb01ed5 (main's current pin) as a single commit again, the stacked CI copy is gone since the fork's main now has that fix. Its release has the same 42 tarballs as main's own 0bb01ed5 release and the preview built on the first attempt. The branch is still the same two commits; only the pin line changed in the conflict resolution. With this preview, bun bd passes jsc-stress 119/119 (the three fixtures included) plus the explicit resource management, mock-disposable and bun-jsc suites, and the three fixtures still assert on the 0bb01ed5 shell. Description updated. Still a draft until #417 merges.

@robobun

robobun commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator Author

No conflict at the moment: the head pushed above (2a24aa6) sits directly on current main (4289e3f, pin 0bb01ed5), GitHub reports the PR as mergeable, and a dry-run merge is clean. The conflict notice referred to the state before that push. CI for the new head is running as build 107161.

@robobun

robobun commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator Author

Main's pin moved to 1817c3c3 (#40681, the upstream upgrade to 6b879687ee), so the WEBKIT_VERSION line conflicts again. Still needed there: the three fixtures assert on the jsc shell from the 1817c3c3 debug-asan prebuilt (loc12, loc21, loc12). The upstream range changes the FTL OSR exit encoding and a few DFG phases, but not the catch handling, the using disposal emission or this phase (the file is byte-identical). oven-sh/WebKit#417 is rebased onto 1817c3c3 (same patch, head 6654f96e) and its preview build is queued. This branch is rebased locally with the pin pointing at that preview; I will push once the release has all 42 tarballs.

@robobun
robobun force-pushed the farm/a3a8c180/dfg-live-catch-nested-handler branch from 2a24aa6 to d7c74ad Compare August 28, 2026 08:07
@robobun

robobun commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed the rebase (d7c74ad). The pin is now autobuild-preview-pr-417-6654f96e, which is oven-sh/WebKit#417 rebased onto 1817c3c3 (main's current pin, the upstream upgrade); its release has the same 42 tarballs as main's own 1817c3c3 release and the preview built on the first attempt. The branch is still the same two commits; only the pin line changed in the conflict resolution. With this preview, bun bd passes jsc-stress 119/119 (the three fixtures included), the explicit resource management, mock-disposable and bun-jsc suites, and the upgrade's own webkit-upgrade-6b879687ee test; the three fixtures still assert on the 1817c3c3 shell. Description updated. Still a draft until #417 merges.

@robobun

robobun commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator Author

CI state for d7c74ad (build 107555): 179 of 182 jobs passed. The three failed jobs are not about this change. The darwin aarch64 test job died before running any test (buildkite-agent artifact download timed out after 120s), and darwin x64 failed test/js/web/url/url.test.ts (the pre-existing IDNA table case), both also on main and both handed to main-break triage. The third is one shard of the debian x64-asan lane, where three of the test/cli/run/require-cache.test.ts leak tests hit their 30s and 60s timeouts; that shard ran 11 minutes against 5 to 6 for its siblings. Those tests load a generated module a few hundred times and check RSS; no try/catch is involved, so the DFG phase change cannot reach them, the same fix passed this file on this lane in builds 106966 and 107161, and main's builds on the same engine base (107291, 107443, 107609) pass it too, while the file is a known flaky one on main (Memory leak detected on Windows in 107094, 107106, 107124, 107413). I cannot retry that one job from here (the Buildkite token is read-only) and I am not pushing an empty commit for it. jsc-stress, including the three fixtures, passed on every lane. Still a draft until oven-sh/WebKit#417 merges and the pin can move to the merged sha.

@robobun

robobun commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator Author

Main's pin moved to ceb9f90f (#40767 and #40677, bytecode cache work plus the IRO ArithAbs fix), so the WEBKIT_VERSION line conflicts again. Still needed there: the three fixtures assert on the jsc shell from the ceb9f90f debug-asan prebuilt (loc12, loc21, loc12); the only DFG file in the range is DFGIntegerRangeOptimizationPhase, the phase here is unchanged. oven-sh/WebKit#417 is rebased onto ceb9f90f (same patch, head adefab25) and its preview build is queued. This branch is rebased locally with the pin pointing at that preview; I will push once the release has all 42 tarballs.

@robobun
robobun force-pushed the farm/a3a8c180/dfg-live-catch-nested-handler branch from d7c74ad to 8604325 Compare August 28, 2026 14:05
@robobun

robobun commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed the rebase (8604325). The pin is now autobuild-preview-pr-417-adefab25, which is oven-sh/WebKit#417 rebased onto ceb9f90f (main's current pin); its release has the same 42 tarballs as main's own ceb9f90f release and the preview built on the first attempt. The branch is still the same two commits; only the pin line changed in the conflict resolution. With this preview, bun bd passes jsc-stress 119/119 (the three fixtures included) plus the explicit resource management, mock-disposable and bun-jsc suites, and the three fixtures still assert on the ceb9f90f shell. Description updated. Still a draft until #417 merges.

@robobun

robobun commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

An eighth fuzzer input landed on this fingerprint (found on d9b7698, pin d71031a9, marked flaky). The crash output in the report has the same shape as the other seven: an FTL compile of a function with for (using ...), catch entrypoints, and the hasError temporary (loc18 there) not available at the dispose call's exception exit, right after the merge block. The reduced script that came with the report cannot reach that code: its for (using v54 of [v42]) loop sits in a nested function f50 that is never called, and the function that does run (a constructor that recurses until the stack overflows, with a try/catch around the recursive call) never reaches the FTL, because every frame exits the DFG code on the way back up (InadequateCoverage at the code after the catch). It did not reproduce here in 11 runs of the fuzzing build (default options, useConcurrentJIT=0, validateGraph=1, lowered FTL thresholds), nor on the d71031a9 shell with the same options. Nothing to change on this branch; for-using-dispose-call-live-catch-locals-ftl-validation.js covers the reported shape.

Main's pin moved to d71031a9 (#40816, the initial GC budget for compiled executables), so the WEBKIT_VERSION line conflicts again. Still needed there: the three fixtures assert on the jsc shell from the d71031a9 debug-asan prebuilt (loc12, loc21, loc12); the three fork commits since ceb9f90f touch only the Heap budget, nothing in the DFG. oven-sh/WebKit#417 is rebased onto d71031a9 (same patch, head f5d2f3a7) and its preview build is running. This branch is rebased locally with the pin pointing at that preview; I will push once the release has all 42 tarballs.

@robobun
robobun force-pushed the farm/a3a8c180/dfg-live-catch-nested-handler branch from 8604325 to ab04e07 Compare September 1, 2026 00:39
@robobun

robobun commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed the rebase (ab04e07). The pin is now autobuild-preview-pr-417-f5d2f3a7, which is oven-sh/WebKit#417 rebased onto d71031a9 (main's current pin); its release has the same 42 tarballs as main's own d71031a9 release and the preview built on the first attempt. The branch is still the same two commits; only the pin line changed in the conflict resolution. With this preview, bun bd passes jsc-stress 119/119 (the three fixtures included) plus the explicit resource management, mock-disposable, bun-jsc and webkit-upgrade suites, and the three fixtures still assert on the d71031a9 shell. Description updated. Still a draft until #417 merges.

@robobun

robobun commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator Author

A ninth fuzzer input landed on this fingerprint (found on d296efb, pin d4e7e206, marked flaky). Same bug, a function shape this time: a constructor F7 recurses through try { new v10(v2); } catch (e) {} until the stack overflows, and every frame then runs for (using v16 of [v6]) { } on the way back up, so F7 gets hot enough for the FTL with the getDisposeMethod call inlined. The local that goes missing is again the hasError temporary (loc20 there; loc19 is pendingError and loc21 is disposeThrew) at the exit right before the dispose call, after the merge of the two getDisposeMethod return paths. It is flaky because it depends on tier-up timing; with --thresholdForFTLOptimizeAfterWarmUp=20 it reproduces every time. Checked against the prebuilts: the fuzzing build (72e75e4e) and the jsc shell from main's current pin 2e2aa229 assert in the FTL compile of F7 (loc20), and on the f5d2f3a7 preview pinned here the same compile completes and the script runs to the end. The mechanism is the one using-dispose-throw-after-body-throw-in-jit.js and using-inlined-dispose-live-catch-locals-ftl-validation.js cover, so nothing to change on this branch.

Main's pin moved to 2e2aa229 (#41297, #41324, the upstream upgrade in #41332, #41378 and #41407), so the WEBKIT_VERSION line conflicts again. Still needed there: the three fixtures assert on the jsc shell from the 2e2aa229 debug-asan prebuilt (loc12, loc21, loc12). The upstream range touches DFGOSRAvailabilityAnalysisPhase only for LoadVarargs heap kills; DFGLiveCatchVariablePreservationPhase and the bytecompiler are byte-identical. oven-sh/WebKit#417 is rebased onto 2e2aa229 (same patch, head dfddac7d) and its preview build is queued. This branch is rebased locally with the pin pointing at that preview; I will push once the release has all 42 tarballs.

@robobun
robobun force-pushed the farm/a3a8c180/dfg-live-catch-nested-handler branch from ab04e07 to 15c3d97 Compare September 5, 2026 08:56
@robobun

robobun commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed the rebase (15c3d97). The pin is now autobuild-preview-pr-417-dfddac7d, which is oven-sh/WebKit#417 rebased onto 2e2aa229 (main's current pin); its release has the same 42 tarballs as main's own 2e2aa229 release and the preview built on the first attempt. The branch is still the same two commits; only the pin line changed in the conflict resolution. With this preview, bun bd passes jsc-stress 119/119 (the three fixtures included) plus the explicit resource management, mock-disposable, bun-jsc and webkit-upgrade suites, the ninth fuzzer input runs to the end with the forced FTL thresholds that make it assert on the 2e2aa229 shell, and the three fixtures still assert on that shell. Description updated. Still a draft until #417 merges.

@robobun

robobun commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

A tenth fuzzer input landed on this fingerprint (found on d316760, pin 2e2aa229, deterministic). It is the first shape again, almost literally the for-using-dispose-call-live-catch-locals-ftl-validation.js fixture: eval code with for (using v5 of v4) { const v7 = {}; try { v7.requestIP(...); } catch (e) {} } followed by a loop that never terminates, so <eval> goes Baseline, DFG, FTLForOSREntry and then a full FTL compile. The local that goes missing in that last compile is the hasError temporary again (loc52 in the report, loc23 with the harness lines stripped; loc51 is pendingError and gets its Phi, loc53 is disposeThrew). Checked against the prebuilts: the fuzzing build and the jsc shell from main's pin 2e2aa229 assert in the FTL compile of <eval> (loc23), and the shell from the dfddac7d preview pinned here completes all four compiles (using FTL with FTL into 4096 bytes) and then just keeps running the input's endless loop. Nothing to change on this branch.

State is otherwise unchanged: head 15c3d97 sits on current main (pin 2e2aa229, no conflict), build 110361 passed 181/181, and this stays a draft until oven-sh/WebKit#417 merges.

@robobun

robobun commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

An eleventh fuzzer input landed on this fingerprint (found on d316760, pin 2e2aa229, deterministic). Same eval shape as the tenth and the first: for (using v5 of [v3]) { try { v5(...); } catch (e) {} } followed by while (536870888) {}, so <eval> reaches a full FTL compile through loop OSR. The missing local is the hasError temporary again (loc28 in the report, loc22 with the harness lines stripped; loc27 is pendingError and has its Phi, loc29 is disposeThrew). The fuzzing build and the jsc shell from main's pin 2e2aa229 assert in that compile within two seconds; the shell from the dfddac7d preview pinned here completes Baseline, DFG, FTLForOSREntry and the full FTL compile and then stays in the input's endless loop. Covered by for-using-dispose-call-live-catch-locals-ftl-validation.js, nothing to change on this branch. Head 15c3d97 is still on current main with no conflict; still a draft until oven-sh/WebKit#417 merges.

…ized code

DFG's LiveCatchVariablePreservationPhase flushed the locals of the handler
being entered instead of the handler being left when one try range led
directly into another. The dispose call emitted for a `using` block ends its
synthesized catch range right at the call, inside the enclosing handler, so
the "body threw" flag that only the synthesized catch reads was never flushed.
FTL compiles of such code failed OSR availability validation, and optimized
code restored the flag as undefined when a dispose method threw after the
body threw, dropping the body's error instead of reporting a SuppressedError.

Pins oven-sh/WebKit#417's preview build and adds both shapes as jsc-stress
fixtures.
…fixture

A second fuzzer input hit the same assertion with the dispose method inlined
into the dispose call (the method is trivial, so inlining does not split the
block) and the function reached through recursion. The original input does
quadratic work, so this is a small deterministic version of that shape; it
fails OSR availability validation on the unfixed engine and passes with the
fix.
@robobun

robobun commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator Author

A twelfth fuzzer input landed on this fingerprint (found on 4ff9193, pin dfd69644, marked flaky). Same eval shape as the tenth and eleventh: for (using v10 of [v8]) { v1[3] = v10; } followed by while (268435441) {}, so <eval> reaches a full FTL compile through loop OSR. This one has no user try/catch at all: the handler that gets entered at the end of the synthesized catch range is the for-of's own iterator-close handler. The missing local is the hasError temporary again (loc53 in the report, loc23 with the harness lines stripped; loc52 is pendingError and has its Phi, loc54 is disposeThrew). It reproduces here every time: the fuzzing build (dfd69644) and the jsc shells from dfd69644 and from main's current pin cf1b36ec assert in that compile within three seconds. Covered by for-using-dispose-call-live-catch-locals-ftl-validation.js, nothing to change on this branch.

Main's pin moved to cf1b36ec (#42002, then the upstream upgrade in #42319), so the WEBKIT_VERSION line conflicts again. Still needed there: the three fixtures assert on the jsc shell from the cf1b36ec debug-asan prebuilt (loc12, loc21, loc12). DFGLiveCatchVariablePreservationPhase is byte-identical across 2e2aa229, dfd69644 and cf1b36ec, and the bytecompiler changes in the range do not touch the using emission. oven-sh/WebKit#417 is rebased onto cf1b36ec (same patch, head db6d1d70) and its preview build is running. This branch is rebased locally with the pin pointing at that preview; I will push once the release has all the tarballs.

@robobun
robobun force-pushed the farm/a3a8c180/dfg-live-catch-nested-handler branch from 15c3d97 to eaf28d4 Compare September 11, 2026 16:29
@robobun

robobun commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed the rebase (eaf28d4). The pin is now autobuild-preview-pr-417-db6d1d70, which is oven-sh/WebKit#417 rebased onto cf1b36ec (main's current pin); its release has the same 42 tarballs as main's own cf1b36ec release and the preview built on the first attempt. The branch is still the same two commits; only the pin line changed in the conflict resolution. With this preview, bun bd passes jsc-stress 119/119 (the three fixtures included) plus the explicit resource management, mock-disposable, bun-jsc and webkit-upgrade suites. The twelfth fuzzer input completes all four compiles of <eval> on the preview's shell (Baseline, DFG, FTLForOSREntry, FTL) and then stays in its endless loop, while the cf1b36ec shell asserts in the FTL compile; the three fixtures still assert on the cf1b36ec shell. Description updated. Still a draft until #417 merges.

@robobun

robobun commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator Author

CI state for eaf28d4 (build 114339): 180 of 181 jobs passed. The failed job is the Windows 2019 x64 test lane. There, test/bake/deinitialization.test.ts crashed with a segmentation fault at address 0x0 in "dev server deinitializes itself". This PR does not cause that crash. The same crash is in the final build of #42213 (build 113977), which ran before the cf1b36ec upgrade and without this engine change. I handed it to main-break triage. Every other failure in the build passed on retry. None of them is in the jsc-stress, explicit resource management, mock-disposable, bun-jsc or webkit-upgrade suites. I cannot retry the Windows job from here. This branch needs no other change until oven-sh/WebKit#417 merges, so it stays a draft.

dylan-conway added a commit that referenced this pull request Sep 15, 2026
…e try range runs into the next (oven-sh/WebKit#629) (#42787)

### What this fixes

In DFG-compiled code, a local that is live only at the head of a `catch`
handler came back as `undefined` after an exception whenever that
handler's try range was followed *directly* by another one. Two ways to
get that bytecode layout:

**`bun build --bytecode` (regression from #42002).** The bytecode
optimizer deletes the `jmp` that closes a try body once an empty `catch
{}` has been threaded to the loop header, so the catch's range falls
through into the next one. This then breaks after tier-up:

```js
function f(kind) {
  for (let name of ["a", "b"]) {
    try {
      return JSON.parse(kind === "k" && name === "b" ? "1" : "{bad"), true;
    } catch {}
  }
  return false;
}
// TypeError: undefined is not a function (near '...name of ["a", "b"]...')
```

It is not specific to for-of or to `JSON.parse`: a `while (true)` inside
`try … finally`, or a labelled `break` into code that starts with a
`try`, loses whatever only the loop uses, and when that is a number
nothing throws — a loop-only `doubled` silently became `NaN`. Building
with `--no-optimize-bytecode` / `optimize: { bytecode: false }` avoided
it.

**`using` (not a regression, all bytecode).** The dispose call's
synthesized catch range ends right at the call, inside the enclosing
handler's range. A dispose method that threw after the body also threw
reported its own `Error` instead of a `SuppressedError` carrying both,
once the function was optimized.

### Cause and fix (oven-sh/WebKit#629)

`DFG::LiveCatchVariablePreservationPhase` flushes, when the covering
exception handler changes, every local live at the catch head of the
handler being left. The lookup of the *new* handler overwrote that live
set before the flush ran, so a direct A → B transition flushed B's set
for A. Locals live only at A's catch were then dead in the block, and
the exception OSR exit to A's `op_catch` recovered them as `undefined`.
Stock `try`/`catch` always ends a range with an explicit `jmp`, so only
the two layouts above reach it.

The phase now looks the handler up, flushes with the old set, and only
then computes the new one, keyed on (handler, inline call frame) so
recursive inlining keeps following the frame. The fixing line is the
reordering in `handleBlockForTryCatch`; everything else in that diff is
the lookup returning the pair.

### Also in this WebKit range

`9b02218df662..65513e295c73`: oven-sh/WebKit#657 (suspended generators
keep their scopes' SymbolTables), #658 (MicrotaskCallCache over zeroed
storage), #583 (no weak `Bun__thisThreadHasVM` fallback — bun defines it
in `VirtualMachine.rs`), #627 (`JSModuleLoader::clearAll()` in one
pass), #624 (DFG constant-folding a module variable across an import
cycle).

### Tests

- `test/bundler/bun-build-compile.test.ts` → `locals live only at a
catch inside a loop`: builds a fixture with `bun build --bytecode` and
runs it; covers for-of (result discarded and used), `while` inside a
user `finally`, labelled `break` into a `try`, the loop-only number that
turns into `NaN`, the for-of inlined into a caller, and a recursively
inlined try/catch on source (that last one is a no-regression check for
the inline-frame keying, it passes before too). JIT thresholds are
lowered in the child's environment so DFG is reached after ~100 calls;
every case goes wrong within 70 iterations on the unfixed engine and the
test runs 300.
- `test/js/web/explicit-resource-management.test.ts` → `a dispose that
throws after the body threw reports a SuppressedError from optimized
code`.

On `1.4.3-canary.1+7e56b402b` (unfixed): the two `--bytecode` cases fail
(`loopOnlyNumber: got false:4:NaN`, `TypeError: undefined is not a
function`) and the `using` test prints `Error | undefined | undefined`.
With this PR (`bun bd test`, debug build on the published prebuilt) all
of them pass. They pass on 1.4.2 as well for the `--bytecode` part,
since that predates the optimizer.

Supersedes #37941, which pinned a preview build of an earlier, now
closed, version of the same engine fix (oven-sh/WebKit#417).
@github-actions

Copy link
Copy Markdown
Contributor

Superseded by #42787.

@github-actions github-actions Bot closed this Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant