Repository navigation
fix(gc tests): zero hand-built Map/Set fixture headers over recycled arena bytes (#11362) - #11363
Conversation
…arena bytes The old-generation Map fixture (duplicated in gc/tests/barrier.rs and gc/tests/helper_stores.rs) wrote only size/used/capacity/entries on a header from arena_alloc_gc_old, which reuses swept holes without zeroing. MapHeader.store (an owned Box) and .meta (a traced edge) kept an earlier test's bytes. At thread exit the arena drop walks every GC_TYPE_MAP header and Box::from_raw's its store; with residue 0x7878787878787878 (an earlier test's "xxx..." string) it faulted in drop_glue<MapStore> after the test had already passed, killing the suite (#11362). Same crash seen under test_incremental_barrier_marks_external_map_and_set_slots. Move the fixture into gc/tests/support.rs, zero the whole header first (as js_map_alloc initialises every word), and do the same for the Set fixture, whose meta/used were also residue. Add a deterministic regression test that poisons the header with 0x78 before initialising it. Fixes #11362
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
💤 Files with no reviewable changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughGC test fixtures now clear header memory before initialization. A barrier regression test poisons a MapHeader, initializes it, and checks selected fields, including the raw store pointer. ChangesGC map header tests
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~15 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The fixture change appears ready to merge after normal checks; no actionable risk remains in the supplied evidence. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 4 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 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 |
|
Loaded mass run: 7 concurrent workers × 30 full-suite runs per arm (
The one SIGSEGV left in the fix arm is a different defect. It happens mid-test, not at thread exit: |
Fixes #11362
Root cause
This was a test-fixture bug (class (b), cross-test residue). The collector is fine.
The crash report for the SIGSEGV shows the faulting frame. It is not in the dirty-page scan at all:
The test's own body passes. The crash happens afterwards, during libtest thread teardown.
Arena::dropwalks everyGC_TYPE_MAPheader (walk_block_maps) and callsdrop_map_store_at_thread_exit, which doesBox::from_raw(header.store).The old-generation Map fixture
alloc_old_test_mapwas duplicated ingc/tests/barrier.rsandgc/tests/helper_stores.rs. It got its header fromarena_alloc_gc_oldand wrote onlysize,used,capacityandentries. That allocator reuses swept same-size holes and bump space without zeroing.js_map_allocsays so explicitly and initialises every word. So the fixture'sstore(an owned Box) andmeta(a traced edge) kept whatever the previous occupant left. Here that was0x7878787878787878, an earlier test's"xxx…"string bytes. Whether the recycled bytes are non-zero depends on what ran earlier in the process, which is why the test passed in isolation (60/60) and failed only in the full suite.The same crash, with the same fault address and stack, also hit a second user of the fixture,
test_incremental_barrier_marks_external_map_and_set_slots.Fix
gc/tests/support.rsasalloc_old_test_map/init_test_map_header/retire_old_test_map. The header is zeroed withwrite_bytesbefore any field is set, sostoreandmetaare always null.alloc_old_test_sethad the same defect:meta(a traced edge),used(the scanned extent) andcompaction_epochwere left as residue. It now zeroes too.map::test_map_store_wordso a test can read the privatestoreword.No collector code changes.
Regression test
gc::tests::barrier::old_test_map_fixture_initialises_every_header_word_over_recycled_bytesfills a fresh old-gen map header with0x78, the way a previous occupant would, and then runs the fixture initialiser. It asserts thatstore,meta,size,usedandcompaction_epochare all zero. It scrubs the header before asserting, so a failing arm fails as a normal test instead of as a thread-exit SIGSEGV.FAILED ... MapHeader.store left: 8680820740569200760 (0x7878787878787878), right: 0, exit 101.ok, exit 0.Validation
perry-runtimelib suite, release,RUST_TEST_THREADS=1: 5 of 5 serial runs clean (4611 passed, exit 0 each).cargo fmt --all -- --check: clean.SKIP_COMPILE_GATES=1 ./scripts/run_lint_gates.sh: 1 of 92 failed. The failure is only "Public benchmark evidence freshness", which is already red on main.Summary by CodeRabbit