T-058: Memory-safety check of the sim core's unsafe code
Goal
The sim core (T-001) uses unsafe code so that many threads can work on different
organisms' cells at once. If that code is wrong, nothing fails loudly. A long run would
slowly corrupt itself, or give different results now and then, and nobody could tell why.
A run that lasts days must be able to trust it. Check it with tools built for this.
Scope
- Find every
unsafeblock incrates/simand write down, next to each, what it relies on to be sound. - Run the sim's tests under Miri (needs the nightly toolchain: install it with rustup, do not change the project's default toolchain). Miri is slow, so pick small worlds, but make sure the parallel paths, births, deaths, splits, merges, defrag and checkpoint load are all reached. Add tests where they are not.
- Run the parallel paths under ThreadSanitizer too if it works on this machine. Say so plainly if it does not.
- Fix what is found. If a fix would cost speed, measure it with
runner benchand say what it costs. - Make it repeatable: one script,
scripts/check-unsafe.sh, and a note indocs/ARCHITECTURE.mdon when to run it (any change that touchesunsafe).
Done when
- ☐ Every
unsafeblock has its reasoning written beside it. - ☐
scripts/check-unsafe.shpasses, and a deliberately planted bug (for example two threads given overlapping ranges) makes it fail. Show both. - ☐ Anything found is fixed or written up as a ticket, with the bench numbers if a hot path changed.