Repository navigation
Add build options for running tests under thread sanitizer #1930
Description
Activity
assigning to @brson since he seems to do Most Things Testsuite.
I presume that we're going to require the user to have installed tsan themselves, and therefore this just needs to be a configuration flag like
--enable-tsanthat then passes the correct flags to the test runner.tsan home page: https://code.google.com/p/data-race-test/wiki/ThreadSanitizer
This has yet to be implemented.
Low, no milestone
A recent article claims that they're on v2 at this point and that it does not have much overhead at all.
Additionally, it sounds like the meaty stuff is implemented in LLVM, we likely just need to have some instrumentation here and there. The part that interests me the most is:
ThreadSanitizer v2 recognizes atomic operations, so it produces far more accurate reports and can also find bugs in lock-free algorithms, which are hard to detect otherwise
That would be amazing to detect, especially for the runtime!
Is this still something we wish to do?
What's the status of this? I'd like to use it for testing the
Arcimplementation.It's currently possible to specify
rustc -C passes=tsan, but the appropriate library isn't linked in:error: linking with `cc` failed: exit code: 1 note: "cc" "-Wl,--as-needed" "-m64" "-L" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib" "foo.0.o" "-o" "foo" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "-L" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/andrew/.rust/lib/x86_64-unknown-linux-gnu" "-L" "/home/andrew/lib/x86_64-unknown-linux-gnu" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-8cf6ce90.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-8cf6ce90.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_unicode-8cf6ce90.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-8cf6ce90.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-8cf6ce90.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-8cf6ce90.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-8cf6ce90.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-8cf6ce90.rlib" "-l" "dl" "-l" "pthread" "-l" "gcc_s" "-l" "rt" "-l" "pthread" "-l" "c" "-l" "m" "-l" "compiler-rt" note: foo.0.o: In function `main': foo.0.rs:(.text.main+0x17): undefined reference to `__tsan_func_entry' foo.0.rs:(.text.main+0x39): undefined reference to `__tsan_func_exit' foo.0.o: In function `tsan.module_ctor': foo.0.rs:(.text.tsan.module_ctor+0x2): undefined reference to `__tsan_init' collect2: error: ld returned 1 exit status error: aborting due to previous errorRelated to #39699.
- addedA-sanitizersArea: Sanitizers for correctness and code qualityArea: Sanitizers for correctness and code quality
on Jun 23, 2017 - addedC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.and removedC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
on Jul 19, 2017 Triage: #39699 is a duplicate and has more up-to-date info.
RIP one of rustc's last four digit issues. <3
- added a commit that references this issue
on Jun 4, 2024 - added a commit that references this issue
on Dec 30, 2024 - added a commit that references this issue
on Jan 2, 2025 - added a commit that references this issue
on Nov 2, 2025
We can now run tests under helgrind. For bonus fun we should be able to run under thread sanitizer (a google-backed valgrind plugin) which does similar-but-different things.