Fix crash in forEachProperty when Proxy getPrototypeOf trap throws#29386
Fix crash in forEachProperty when Proxy getPrototypeOf trap throws#29386robobun wants to merge 1 commit into
Conversation
When walking the prototype chain during property enumeration for the console formatter, getPrototype() can throw (e.g. via a Proxy trap), returning an empty JSValue. Calling .getObject() on that empty value dereferences a null cell pointer. Clear the exception and stop walking the chain instead, matching the behavior of the other getPrototype() call sites in this function.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughUpdated prototype-chain iteration in JSC value inspection to handle exceptions from Proxy Changes
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
This PR may be a duplicate of:
🤖 Generated with Claude Code |
There was a problem hiding this comment.
LGTM — targeted crash fix with matching test.
Extended reasoning...
Overview
Fixes a segfault in JSC__JSValue__forEachPropertyImpl (bindings.cpp) that occurred when walking the prototype chain during property enumeration and a Proxy getPrototypeOf trap throws. The fix adds null-check and exception clearing before dereferencing the returned JSValue, plus a regression test in inspect.test.js.
Security Risks
None. The change only adds defensive handling for an exception path, preventing a crash. It does not affect auth, crypto, or permissions.
Level of Scrutiny
Low — this is a single-site, surgical crash fix with a clear repro. The CLEAR_IF_EXCEPTION pattern is already used in two other nearby call sites in the same function (lines ~5223 and ~5258), making this straightforwardly consistent.
Other Factors
No bugs were found by the automated bug hunter. The test directly reproduces the crash scenario. The change is 5 lines of C++ and 16 lines of test code.
When walking the prototype chain during property enumeration for the console formatter (
Bun.inspect/console.log),getPrototype()can throw — e.g. via a ProxygetPrototypeOftrap — returning an emptyJSValue. Calling.getObject()on that empty value dereferences a null cell pointer and crashes.Clear the exception and stop walking the chain instead, matching the behavior of the other
getPrototype()call sites in the same function.Repro
Before:
Segmentation fault at address 0x5After:
{}Fuzzer fingerprint:
6ba473c2ca8e03e1