Making Unsafe Rust Safer: Verification Tools for Unsafe Code
Rust's popularity stems from its ability to eliminate memory and concurrency errors at compile time, but its `unsafe` code blocks can bypass these checks. This article explores tools for verifying unsafe Rust code, including code called from C or C++ libraries. It introduces runtime error detection tools—sanitizers—and Miri, an interpreter that deterministically finds undefined behavior. Sanitizers detect out-of-bounds memory access, data races, and more, while Miri provides more precise error reporting with code snippets. However, Miri currently doesn't support code called via FFI from C/C++, necessitating the use of C/C++ compiler sanitizers in such cases. These tools enhance the safety and reliability of Rust code, even when dealing with `unsafe` code or interacting with C/C++ libraries.
Read more