Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests under AddressSanitizer (and possibly other sanitizers) #151

Open
robertknight opened this issue May 5, 2024 · 0 comments
Open
Labels
qa Quality / correctness checks

Comments

@robertknight
Copy link
Owner

robertknight commented May 5, 2024

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 robertknight added the qa Quality / correctness checks label May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
qa Quality / correctness checks
Projects
None yet
Development

No branches or pull requests

1 participant