Summary
PulseMap contains several unsafe blocks:
SlabPool (src/engine/slab.rs): Manual heap allocation via std::alloc::Layout, raw pointer reads/writes
MetaWord (src/engine/meta.rs): AtomicU64 with Relaxed ordering
PulseMapRaw (src/raw.rs): unsafe impl Send (intentionally no Sync)
AccessBuffer (src/engine/access_buffer.rs): unsafe impl Send + Sync
simd.rs: unsafe SSE2 intrinsics
Miri is Rust's official interpreter for detecting undefined behavior (UB) at runtime. Running the existing test suite under Miri can catch memory errors that normal tests miss: use-after-free, out-of-bounds access, invalid pointer alignment, and violations of Rust's aliasing model (Stacked Borrows).
What To Do
1. Try running the existing tests under Miri
rustup +nightly component add miri
cargo +nightly miri test -p pulse_map --no-default-features # core engine only
cargo +nightly miri test -p pulse_map # with std features
2. Document and fix any Miri violations
- If Miri reports UB, create a separate issue for each distinct violation with the full Miri backtrace
- Common findings in projects like this:
- Stacked Borrows violations from casting
&self to *mut (we already fixed the big one in v0.6.2)
- Alignment issues in
repr(C, packed) structs (our Slot is packed)
- Provenance issues in the
SlabPool raw pointer usage
3. Add Miri to CI
Add a new job in .github/workflows/build.yml:
- name: Run Miri
run: |
rustup +nightly component add miri
cargo +nightly miri test -p pulse_map --no-default-features
Known Limitations
- Miri does not support inline assembly or SIMD intrinsics. Tests using the
simd feature will need to be skipped (--no-default-features avoids this)
- Miri is slow (~100x slower than normal execution). This is expected.
Acceptance Criteria
Summary
PulseMap contains several
unsafeblocks:SlabPool(src/engine/slab.rs): Manual heap allocation viastd::alloc::Layout, raw pointer reads/writesMetaWord(src/engine/meta.rs):AtomicU64withRelaxedorderingPulseMapRaw(src/raw.rs):unsafe impl Send(intentionally noSync)AccessBuffer(src/engine/access_buffer.rs):unsafe impl Send + Syncsimd.rs:unsafeSSE2 intrinsicsMiri is Rust's official interpreter for detecting undefined behavior (UB) at runtime. Running the existing test suite under Miri can catch memory errors that normal tests miss: use-after-free, out-of-bounds access, invalid pointer alignment, and violations of Rust's aliasing model (Stacked Borrows).
What To Do
1. Try running the existing tests under Miri
2. Document and fix any Miri violations
&selfto*mut(we already fixed the big one in v0.6.2)repr(C, packed)structs (ourSlotis packed)SlabPoolraw pointer usage3. Add Miri to CI
Add a new job in
.github/workflows/build.yml:Known Limitations
simdfeature will need to be skipped (--no-default-featuresavoids this)Acceptance Criteria
cargo +nightly miri test --no-default-features.github/workflows/build.yml