Repository navigation
Conversation
|
Updated 11:25 AM PT - Mar 25th, 2026
❌ @robobun, your commit e81788e has 3 failures in
🧪 To try this PR locally: bunx bun-pr 28562That installs a local version of the PR into your bun-28562 --bun |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between add1be46c573bde2465254ff0c21dfef2f69fd60 and e81788e. 📒 Files selected for processing (2)
WalkthroughPatch updates JavaScriptCore’s dump logic to avoid dereferencing a null Changes
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@test/js/bun/jsc/dfg-null-butterfly-dump.test.ts`:
- Around line 36-37: Remove the two assertions that check stderr for absence of
runtime strings: delete the lines containing expect(stderr).not.toContain("null
pointer") and expect(stderr).not.toContain("runtime error") from the test
(dfg-null-butterfly-dump.test.ts) so the test no longer asserts absence of
panic/runtime text; leave the remaining stderr expectations intact.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: dd0a10d9-3518-4351-a214-a60179fd5aee
📥 Commits
Reviewing files that changed from the base of the PR and between 1879e9e and 2e6013d83db44e1ceb5a9edc8aa3adbb13ccab52.
📒 Files selected for processing (2)
patches/webkit/fix-null-butterfly-dump.patchtest/js/bun/jsc/dfg-null-butterfly-dump.test.ts
There was a problem hiding this comment.
LGTM — straightforward null-guard fix in debug/dump-only code path with a regression test.
Extended reasoning...
Overview
This PR adds a WebKit patch (patches/webkit/fix-null-butterfly-dump.patch) that guards a null pointer dereference in JSValue::dumpInContextAssumingStructure, and a regression test in test/js/bun/jsc/dfg-null-butterfly-dump.test.ts. Only two files are changed.
Security Risks
None. The affected code path is the DFG graph dump/debug printer, which runs during validation failures and diagnostic output — not in any production execution path. There is no user-controlled input reaching this code.
Level of Scrutiny
Low. The fix is a one-liner null check added to a diagnostic print function. The logic is self-evident: butterfly() may return nullptr for objects with only inline properties, and the fix avoids dereferencing it. The change is explicitly an upstream WebKit fix applied via the patches mechanism.
Other Factors
No bugs were found by the automated hunting system. The regression test exercises the exact scenario described (DFG validation with objects that have null butterflies) and checks for absence of UBSAN output and a clean exit code. The change is well-scoped and carries no design decisions requiring human judgment.
There was a problem hiding this comment.
The C++ patch is correct, but please address the outstanding reviewer comment about the test — the expect(stderr).not.toContain(...) assertions violate the project guideline against checking for absence of panic/runtime-error strings in test output.
Extended reasoning...
Overview
This PR adds a WebKit patch (patches/webkit/fix-null-butterfly-dump.patch) that fixes a null butterfly dereference in JSValue::dumpInContextAssumingStructure, and a regression test at test/js/bun/jsc/dfg-null-butterfly-dump.test.ts.
The Patch
The fix is minimal and clearly correct: cache the butterfly() result, guard with a null check, and only print base= when non-null. This is exactly the right approach for a UBSAN-detected null-dereference in a debug/dump path. No security concerns; no logic changes to production code paths.
The Test
The test has an outstanding issue from coderabbitai (unaddressed by the author): lines 36–37 assert expect(stderr).not.toContain("null pointer") and expect(stderr).not.toContain("runtime error"). Per the project coding guidelines, tests must never check for the absence of panic/runtime-error strings — these assertions will never catch failures in normal CI builds because UBSAN output requires special sanitizer build flags. This is a genuine pattern violation, not a style nit.
Level of Scrutiny
The fix itself is low risk and routine. I would normally approve it. However, there is an open reviewer comment that the author has not yet addressed, and the test pattern violation is a real concern per project guidelines.
Other Factors
The build failures mentioned by robobun reference commit 7c289b8, which is the prior commit on master — they are unrelated to this PR. There are no security-sensitive code paths involved.
JSCJSValue::dumpInContextAssumingStructure unconditionally dereferences the return value of butterfly() when printing JSObject constants. Objects with only inline properties have a null butterfly, causing undefined behavior when the DFG graph dump is triggered (e.g. during validation failures). Add a null check before calling butterfly->base(structure).
bd5007c to
e81788e
Compare
There was a problem hiding this comment.
LGTM — the stderr pipe deadlock concern from my previous review has been addressed, and the null butterfly fix is correct.
Extended reasoning...
Overview
This PR adds a WebKit patch (patches/webkit/fix-null-butterfly-dump.patch) that fixes a null pointer dereference in JSValue::dumpInContextAssumingStructure, and a regression test (test/js/bun/jsc/dfg-null-butterfly-dump.test.ts). The patch is minimal: cache the butterfly pointer, null-check before dereferencing, and fall through to printing without the base offset if null.
Security risks
None. This is a diagnostic/dump code path only reached during DFG graph validation. No auth, crypto, or permission code is touched.
Level of scrutiny
Low. The fix is a textbook null guard on a single pointer dereference in debug/dump output code. The patch matches the description exactly. The test correctly uses stderr: "ignore", asserts stdout === "ok\n", and checks exitCode === 0.
Other factors
My previous review flagged a potential pipe deadlock (the test had stderr: "pipe" but never consumed it). That was addressed in commit bd5007c. The current diff already reflects stderr: "ignore". No further issues remain. No bugs were found by the automated bug hunting system.
| --- a/Source/JavaScriptCore/runtime/JSCJSValue.cpp | ||
| +++ b/Source/JavaScriptCore/runtime/JSCJSValue.cpp | ||
| @@ -311,7 +311,11 @@ void JSValue::dumpInContextAssumingStructure(PrintStream& out, DumpContext* cont | ||
| else if (structure->classInfoForCells()->isSubClassOf(JSObject::info())) { | ||
| out.print("Object: ", RawPointer(asCell())); | ||
| - out.print(" with butterfly ", RawPointer(asObject(asCell())->butterfly()), "(base=", RawPointer(asObject(asCell())->butterfly()->base(structure)), ")"); | ||
| + auto* butterfly = asObject(asCell())->butterfly(); | ||
| + if (butterfly) | ||
| + out.print(" with butterfly ", RawPointer(butterfly), "(base=", RawPointer(butterfly->base(structure)), ")"); | ||
| + else | ||
| + out.print(" with butterfly ", RawPointer(butterfly)); | ||
| out.print(" (Structure ", inContext(*structure, context), ")"); |
There was a problem hiding this comment.
🔴 The patch patches/webkit/fix-null-butterfly-dump.patch is never applied by the build system — it exists only as documentation. WebKit is integrated as a prebuilt binary via SetupWebKit.cmake, which does not invoke GitClone.cmake's patch-application logic used by all other vendored libraries. Additionally, WEBKIT_VERSION in SetupWebKit.cmake was last updated three days before this PR was opened, meaning the current prebuilt binary cannot contain this fix. To actually ship the fix, it must be committed to the oven-sh/WebKit fork, new prebuilt binaries must be built, and WEBKIT_VERSION must be updated.
Extended reasoning...
How the build system applies patches
Every vendored C/C++ library in the Bun repo that has patches under patches/<name>/ uses register_repository() in its cmake file (e.g., highway, libarchive, libuv, lshpack, brotli, zlib). register_repository() calls into cmake/scripts/GitClone.cmake, which — at line 44 — iterates over patches/${GIT_NAME}/ and applies each .patch file to the cloned source. This is the one and only mechanism for applying patches in this repo.
Why WebKit is different — and why that breaks the fix
WebKit is not cloned via register_repository(). Instead, cmake/tools/SetupWebKit.cmake handles it via two completely separate code paths: (a) the default path downloads a prebuilt binary tarball from oven-sh/WebKit GitHub releases; (b) the WEBKIT_LOCAL=1 path configures cmake from vendor/WebKit source. Neither path invokes GitClone.cmake or reads from patches/webkit/. No other script in the repository references patches/webkit/ — the directory was created fresh by this PR with no prior precedent.
The WEBKIT_VERSION timestamp seals it
The WEBKIT_VERSION hash (fc9f2fa7272fec64905df6a9c78e15d7912f14ca) in SetupWebKit.cmake was set by PR #28371, merged on March 22, 2026. This PR was opened on March 25, 2026 — three days later. The prebuilt binary that Bun downloads during a normal build was therefore produced before this fix was written. Even if the patch were applied to the oven-sh/WebKit fork today, the binary pointed to by the current WEBKIT_VERSION would still be unpatched.
Addressing the refutation
One verifier argued this is intentional — patches/webkit/ is documentation of upstream changes made to the fork, and WEBKIT_VERSION might already point to a commit containing the fix. This does not hold up:
- CONTRIBUTING.md explicitly states: "if you make changes to our WebKit fork (oven-sh/webkit), you will also have to change SetupWebKit.cmake to point to the commit hash." This PR does not update
WEBKIT_VERSION. - The three-day timestamp gap is dispositive: the current prebuilt binary was produced before this fix was written, so it cannot contain the fix.
- No established pattern:
patches/webkit/is newly created by this PR; there is no repo history of it serving as a documentation-only changelog.
Impact
The PR title and description claim to fix a UBSAN null-pointer dereference (butterfly()->base(structure) called with null butterfly). Any Bun binary built from this repo will still contain the unfixed WebKit code. The regression test may pass vacuously if the specific JIT path that triggers the null butterfly dump is not exercised on the unpatched binary, masking the incomplete fix.
Step-by-step proof
- Developer builds Bun from this PR:
cmakerunsSetupWebKit.cmake. SetupWebKit.cmakedownloads the prebuilt tarball identified byWEBKIT_VERSION = fc9f2fa7272fec64905df6a9c78e15d7912f14ca(built March 22, 2026).- No code path reads
patches/webkit/fix-null-butterfly-dump.patchor applies it. - The resulting
libJavaScriptCorein the tarball still contains the originalbutterfly()->base(structure)call with no null check. - The built
bunbinary still triggers UBSAN when DFG dumps a JSConstant with a null butterfly.
Correct fix
Apply the change in the patch to the oven-sh/WebKit fork, trigger a new prebuilt WebKit build, and update WEBKIT_VERSION in SetupWebKit.cmake to the new commit hash — as CONTRIBUTING.md requires.
|
Closing this PR because it has been inactive for more than 90 days. |
What
Fix undefined behavior in
JSCJSValue::dumpInContextAssumingStructurewherebutterfly()->base(structure)is called without checking ifbutterfly()returns null.Why
When the DFG compiler dumps its graph (e.g. during validation failures), it prints JSConstant nodes that reference heap objects. For objects with only inline properties (no indexed storage, no out-of-line properties),
butterfly()returnsnullptr. The dump code unconditionally dereferences this null pointer to call->base(structure), triggering undefined behavior caught by UBSAN:The call chain is:
Fix
Add a null check on the butterfly pointer before calling
->base(). When null, just print the pointer value without the base offset.This is an upstream WebKit fix (the patch is in
patches/webkit/). The change is invendor/WebKit/Source/JavaScriptCore/runtime/JSCJSValue.cpp.Fuzzilli fingerprint:
Butterfly.h:182:21:member call on null pointer of type 'JSC::Butterfl