rten icon indicating copy to clipboard operation
rten copied to clipboard

Run tests under AddressSanitizer (and possibly other sanitizers)

Open robertknight opened this issue 1 year ago • 0 comments

Some packages (eg. rten-tensor) can be run under Miri to check for bugs. There are tests in the main rten crate which run much too slowly under Miri however. Instead these tests can be run under ASAN or other sanitizers. Aside from ASAN, the other sanitizers that would be most useful are MemorySanitizer and ThreadSanitizer to check for uninitialized reads and data races respectively.

Locally I was able to run the library tests under ASAN with:

RUSTFLAGS=-Zsanitizer=address cargo +nightly test -Zbuild-std --target x86_64-apple-darwin --lib

--target needs to be adjusted as appropriate.

Some notes:

  • In my testing, using -Zbuild-std was necessary to catch a dummy bug that I inserted (an out-of-bounds read)
  • The --lib flag is needed to skip doctests, as these failed to compile under ASAN

robertknight avatar May 05 '24 09:05 robertknight