fix(gc): widen field_count before a by-index FFI field store (#7164) - #7705
Conversation
|
Warning Review limit reached
Next review available in: 2 minutes 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 ignored due to path filters (1)
📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe indexed field setter now widens ChangesIndexed field publication and GC coverage
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
The collector's payload view is bounded by field_count, so a store at an index the count did not cover was invisible to tracing AND to evacuation rewriting. Same publication-order invariant field_set_by_name/tail.rs already enforces; only the by-index path was missing it. Claude-Session: https://claude.ai/code/session_01Y1QZ5wUP9gRSwpiweT4Wix
2f55ffa to
fc1744a
Compare
Closes #7164.
perry_ffi::alloc_object()allocates withfield_count = 0andINLINE_SLOT_FLOORphysical slots. The documented by-index writerjs_object_set_fieldbounds-checksfield_indexagainstmax(field_count, INLINE_SLOT_FLOOR)— so it accepts an index at or abovefield_count— but never widenedfield_countto cover it.object::gc_field_slot_rangebounds the collector's view of the payload byfield_count, andheap_payload_slot_selectionshort-circuits toEmptyon an empty payload before consulting the per-object pointer mask. So a pointer written through this setter was invisible to both tracing (never marked → swept while live) and to evacuation rewriting (stale from-space pointer left in a live slot).The
0x9slot in the issue's SIGSEGV is downstream wreckage, not the defect — which is why the test does not chase it.This is the by-index counterpart of the "#7154 publication order" invariant
field_set_by_name/tail.rsalready enforces at two sites; only this path was missing it. Widening before the store is safe: the existing bounds check already holdsfield_indexbelow the physical capacity, and every physical slot isundefined-initialized at allocation, so the widened range can only expose non-pointer sentinels ahead of the store about to fill this one.On the test not being vacuous
It asserts the defect deterministically, without racing a collector: it checks that
gc_child_slots— the enumerator every mark/scan/evacuation pass calls — reports the written slot at all. Without the fix it enumerates[]. It then runs a real copying minor gated oncopied_objects > 0, so a run that collected nothing cannot report success.Verified by reverting only the two-line widen and re-running:
cargo test -p perry-runtime --lib: 1945 passed, 0 failed.Summary by CodeRabbit
Bug Fixes
Tests
Documentation