Repository navigation
fix(interp): box a ref local only while its register is loaded - #204
Conversation
|
Warning Review limit reached
Next review available in: 14 minutes Limit details: You’ve used all 1 included review currently available under your plan. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #204 +/- ##
==========================================
- Coverage 22.92% 22.92% -0.01%
==========================================
Files 87 87
Lines 70125 70127 +2
==========================================
Hits 16077 16077
- Misses 52802 52804 +2
Partials 1246 1246 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
A native call invalidates the caller's cached local registers, because the callee owns every allocatable register: the call sites clear activation.state on return, and the committing flush before the call leaves the VM stack slot authoritative. activation.locals still names the register each value was last materialized into, so guardFrame - which reads every ref local for the frame teardown - boxed whatever the callee had left there and released it. Reading i.rc at that address faults inside the Go runtime rather than diverging quietly. Give the rule one owner. activation.isLoadedAt answers whether the cached register is still good; guardFrame and loadLocal both ask it instead of testing the state flag inline, and guardFrame's separate register-width check goes away because a loaded slot always names a register. Baseline Call_IndirectRecursiveFib default 489 us, result 69 us, conclusion the stale box could also fail and reject the whole plan, so a shape that never compiled now does - 7.1x over four interleaved rounds, and it passes the threaded tier (553 us) for the first time. Every other kernel is unchanged: median +0.1% across 18 kernels, 3 rounds. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
452765d to
2301f41
Compare
Two symbols sat outside their group. elemShape, a private type, was declared between the constant and variable groups, and isLoadedAt, a private method, between two private types. Both are moves only. elemShape joins the private types and gains the doc comment its fields were missing; isLoadedAt follows newActivation, the constructor of the type it answers for. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Fixes the SIGSEGV left open by #201/#203, and unblocks a kernel that had never compiled.
Root cause
A native call invalidates the caller's cached local registers — the callee owns every allocatable register, so the call sites
clear(activation.state)on return, and the committing flush before the call leaves the VM stack slot authoritative.activation.localsstill names the register each value was last materialized into.guardFrame, which reads every ref local for the frame teardown, decided purely on that register being set:So the teardown boxed whatever the callee had left in that register and released it. Reading
i.rcat that address faults inside the Go runtime rather than diverging quietly.The rule now has one owner:
activation.isLoadedAtanswers whether the cached register is still good, andguardFrameandloadLocalboth ask it instead of testing the state flag inline.guardFrame's separate register-width check goes away with it — a loaded slot always names a register.guardFramewas the only reader that consultedlocalswithout the state; the others go throughloadLocalor gate onlocalDirty.How it was found
Black-box probing eliminated seven hypotheses (spill frame/X26,
i.rcgrowth, hot-exit folding, carried legs, buffer overwrite, reinstall over a live entry, fallback capture) before dumping the callable and disassembling it. The fault PC is a stable offset0x39c:X2is written at0x0064/0x0068as the boxed ref constant, then lives across twoBL ctx.headself-calls that clobber it.Effect beyond the crash
The stale box could also fail, rejecting the whole plan — so a shape that never compiled now does:
Call_IndirectRecursiveFibdefault, maindefault, this PRthreaded(unchanged)7.1x, confirmed over four interleaved rounds (488–491 µs vs 68.7–69.0 µs), and it passes the threaded tier for the first time. Every other kernel is unchanged: median +0.1% across 18 kernels, 3 interleaved rounds.
docs/benchmarks.mdcarries the updated row.Test
TestARM64_SelfCallFrameLocals— self-recursion with a ref local read before it is written (which is what gives it a cached register live across the call), depth 8,WithTick(1), 16 rounds against aWithThreshold(-1)twin asserting value andrcparity, plus that native code was actually installed. Without the fix it faults.Verification
go test -race ./...,make lint,make check-generated,make fuzz, and aGOOS=linux GOARCH=amd64build all pass.docs/jit-internals.mdrecords the invalidation contract next to the X26 one.🤖 Generated with Claude Code