fix(runtime): guard URLSearchParams dynamic-call fast-path against handle receivers#6049
fix(runtime): guard URLSearchParams dynamic-call fast-path against handle receivers#6049proggeramlug wants to merge 1 commit into
Conversation
…t handle receivers A fused dynamic method call (`v.append(...)` where `v`'s static Web-Fetch type was erased — an `any`/untyped local, or a destructured binding) routes through `js_native_call_method`. Its #5961 URLSearchParams fast-path matches the method names `append`/`set`/`get`/`has`/`delete`/`toString` and derefs the receiver as a heap `ObjectHeader` to sniff the `_entries` shape. But a `Headers` instance (and every fetch/timer/... value) is a native *handle*: nanbox-pointer-tagged, yet its "pointer" is a small integer id in the low handle band, not a heap object. Dereferencing it as an `ObjectHeader` SIGSEGV'd. The WHATWG NullableHeaders builder triggers exactly this, calling `K.delete(name)` / `K.append(name, value)` on destructured (type-erased) names. Add an `is_pointer()` + `is_small_handle` guard before the deref so handle receivers fall through to `handle_method_dispatch`, which owns the fetch/Headers method surface. Regression test compiles + runs the NullableHeaders builder shape and reads the result back through an untyped local.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a guard in ChangesSmall Handle Guard and Regression Test
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Closing — this turned out to be a non-issue on |
Problem
A fused dynamic method call —
v.append(...)wherev's static Web-Fetch type was erased (stored in anany/untyped local, or a destructured binding) — routes throughjs_native_call_method. Its #5961 URLSearchParams fast-path matches the method namesappend/set/get/has/delete/toStringand dereferences the receiver as a heapObjectHeaderto sniff the_entriesshape:But a
Headersinstance — and every fetch / timer / ... value — is a native handle: nanbox-pointer-tagged, yet its "pointer" is a small integer id in the low handle band, not a heap object. Dereferencing that id as anObjectHeaderSIGSEGVs (fault address in the low handle band).The WHATWG NullableHeaders builder hits this directly — destructured (type-erased) names flow into
Headersmethods:Minimal repro (SIGSEGV before the fix):
Fix
Guard the fast-path with
jsval.is_pointer()+!is_small_handle(recv_ptr)before the deref, so a handle receiver falls through tohandle_method_dispatchbelow (which owns the fetch/Headers method surface). Real URLSearchParams instances are heap objects and are unaffected.Test
crates/perry/tests/issue_dynamic_call_headers_handle.rscompiles + runs the NullableHeaders builder shape (destructured names intodelete/append, dedup across lists) and reads the result back through an untyped local:ct=application/json beta=on hasCT=true.Summary by CodeRabbit
Bug Fixes
Tests