Turning On the Debug Options That Catch What Rust Cannot
Rust's compiler prevents many memory and threading mistakes, but a driver still contains unsafe code and still calls into C, where those guarantees stop. The kernel has build-time options that watch memory accesses and lock ordering at runtime and shout the moment something is wrong, at the cost of speed. You switch them on in your development kernel and leave them off in a real one. They catch, at the exact moment it happens, the bug that would otherwise show up as a random crash an hour later.
Questions this Concept answers
- Why does a driver written in Rust still benefit from a development kernel built with `CONFIG_KASAN` and `CONFIG_PROVE_LOCKING`?
Linux Kernel Debugging
This guide shows how to set up a kernel you can actually debug. It lists the build options to switch on while you are developing, such as the ones that watch every memory access and the ones that tra…