fix(vm): grow-only dropped-segment bitset in data.drop/elem.drop - #172
fix(vm): grow-only dropped-segment bitset in data.drop/elem.drop#172dmitry123 wants to merge 1 commit into
Conversation
|
Warning Review limit reached
Next review available in: 59 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 selected for processing (4)
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 |
Criterion results (vs baseline)Heads-up: runner perf is noisy; treat deltas as a smoke check. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Fixes FLU-1100.
Problem
visit_data_dropandvisit_element_dropusedBitVec::resize(idx + 1, false)to make room for the bit they set.resizealso shrinks, so dropping a lower-indexed segment after a higher-indexed one truncated the bitset and discarded the record of the earlier drop:Per the Wasm spec a dropped segment must behave as zero-length, so
memory.init/table.initon it has to trap. rwasm instead succeeded and copied data — a state divergence from wasmtime on the same module.Fix
Grow the bitset only when the index is beyond its current length, then set the bit. Applied identically in
visit_data_drop(src/vm/executor/memory.rs) andvisit_element_drop(src/vm/executor/table.rs).Segment indices are bounded by
N_MAX_DATA_SEGMENTS/N_MAX_ELEM_SEGMENTS(100_000) inverify_opcodefor all four opcodes that reach these paths (MemoryInit,DataDrop,TableInit,ElemDrop), so worst-case growth stays at ~12.5 KiB per bitset.Tests
New
tests/segment_drop.rscovers both opcodes with three cases each: no drop (succeeds), single drop (traps), and descending drop5then2(must still trap). Both descending cases fail ondeveland pass with the fix.The fuzz generator is nudged toward the pattern that was missed:
min_data_segments/min_element_segmentsare set to 4 infuzz/fuzz_targets/differential.rs, so generated modules reliably contain several segments and can emit descending drop sequences. Note therwasm-fuzzcrate does not compile ondevelfor an unrelated reason (a missingContexttrait import atdifferential.rs:709), so that change is unverified by a build.Verification
cargo test— full suite greencargo clippy --all-targets— clean