How to use Dataflow sanitizer?

⚓ Rust    📅 2026-04-28    👤 surdeus    👁️ 4      

surdeus

Hi. I'm trying to instrument a program using LLVM/Clang's Dataflow sanitizer, but have not been successful.

Here is my setup, which is inspired by the test cases in the compiler's repo:

  1. A crate with main.rs defined as in tests/ui/sanitizer/dataflow.rs.
  2. A abilist.txt defined as in tests/ui/sanitizer/dataflow-abilist.txt
  3. RUSTFLAGS set to -Zsanitizer=dataflow -Zsanitizer-dataflow=abilist.txt -Cunsafe-allow-abi-mismatch=sanitizer.
  4. Building with cargo build -Zbuild-std --target x86_64-unknown-linux-gnu

Then the build fails in linking due to undefined symbols, which should be instrumented version of the stdlib.

  = note: rust-lld: error: undefined symbol: _Unwind_RaiseException.dfsan
          >>> referenced by gcc.rs:72 (src/gcc.rs:72)
          >>>               panic_unwind-08cd9740da1a8428.panic_unwind.f5942db226e6de1f-cgu.0.rcgu.o:(panic_unwind::imp::panic (.dfsan)) in archive ~/dfsan_test/dummy/target/x86_64-unknown-linux-gnu/debug/deps/libpanic_unwind-08cd9740da1a8428.rlib
          
          rust-lld: error: undefined symbol: _Unwind_DeleteException.dfsan
          >>> referenced by gcc.rs:89 (src/gcc.rs:89)
          >>>               panic_unwind-08cd9740da1a8428.panic_unwind.f5942db226e6de1f-cgu.0.rcgu.o:(panic_unwind::imp::cleanup (.dfsan)) in archive ~/dfsan_test/dummy/target/x86_64-unknown-linux-gnu/debug/deps/libpanic_unwind-08cd9740da1a8428.rlib
          
          rust-lld: error: undefined symbol: open64.dfsan
          >>> referenced by mod.rs:69 (src/sys/pal/unix/mod.rs:69)
          >>>               std-63b5deb51138cac5.std.5705bc538c5524d2-cgu.04.rcgu.o:(std::sys::pal::unix::init::sanitize_standard_fds::{closure#0}) in archive ~/dfsan_test/dummy/target/x86_64-unknown-linux-gnu/debug/deps/libstd-63b5deb51138cac5.rlib
          >>> referenced by unix.rs:1368 (src/sys/fs/unix.rs:1368)
          >>>               std-63b5deb51138cac5.std.5705bc538c5524d2-cgu.09.rcgu.o:(<std::sys::fs::unix::File>::open_c::{closure#0}) in archive ~/dfsan_test/dummy/target/x86_64-unknown-linux-gnu/debug/deps/libstd-63b5deb51138cac5.rlib
          
          rust-lld: error: undefined symbol: dup.dfsan
          >>> referenced by mod.rs:65 (src/sys/pal/unix/mod.rs:65)
          >>>               std-63b5deb51138cac5.std.5705bc538c5524d2-cgu.04.rcgu.o:(std::sys::pal::unix::init::sanitize_standard_fds::{closure#0}) in archive ~/dfsan_test/dummy/target/x86_64-unknown-linux-gnu/debug/deps/libstd-63b5deb51138cac5.rlib
          
          rust-lld: error: undefined symbol: abort.dfsan
          >>> referenced by mod.rs:75 (src/sys/pal/unix/mod.rs:75)
          >>>               std-63b5deb51138cac5.std.5705bc538c5524d2-cgu.04.rcgu.o:(std::sys::pal::unix::init::sanitize_standard_fds::{closure#0}) in archive ~/dfsan_test/dummy/target/x86_64-unknown-linux-gnu/debug/deps/libstd-63b5deb51138cac5.rlib
          >>> referenced by mod.rs:305 (src/sys/pal/unix/mod.rs:305)
          >>>               std-63b5deb51138cac5.std.5705bc538c5524d2-cgu.04.rcgu.o:(std::sys::pal::unix::abort_internal) in archive ~/dfsan_test/dummy/target/x86_64-unknown-linux-gnu/debug/deps/libstd-63b5deb51138cac5.rlib
          >>> referenced by mod.rs:114 (src/sys/pal/unix/mod.rs:114)
          >>>               std-63b5deb51138cac5.std.5705bc538c5524d2-cgu.04.rcgu.o:(std::sys::pal::unix::init::sanitize_standard_fds) in archive ~/dfsan_test/dummy/target/x86_64-unknown-linux-gnu/debug/deps/libstd-63b5deb51138cac5.rlib

...

I guess it's because some sanitizer library is not being linked correctly. Does anybody what is missing?

1 post - 1 participant

Read full topic

🏷️ Rust_feed