Skip to content

Add build options for running tests under thread sanitizer #1930

Description

@brson

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.

Activity

  1. ghost assigned on Mar 8, 2012
  2. catamorphism commented on Mar 8, 2012

    @catamorphism
    Contributor

    assigning to @brson since he seems to do Most Things Testsuite.

  3. bstrie commented on Jun 24, 2013

    @bstrie
    Contributor

    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-tsan that then passes the correct flags to the test runner.

    tsan home page: https://code.google.com/p/data-race-test/wiki/ThreadSanitizer

  4. thestinger commented on Sep 9, 2013

    @thestinger
    Contributor

    This has yet to be implemented.

  5. catamorphism commented on Oct 24, 2013

    @catamorphism
    Contributor

    Low, no milestone

  6. alexcrichton commented on Apr 21, 2014

    @alexcrichton
    Member

    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!

  7. steveklabnik commented on Jan 20, 2015

    @steveklabnik
    Contributor

    Is this still something we wish to do?

  8. apasel422 commented on Nov 1, 2015

    @apasel422
    Contributor

    What's the status of this? I'd like to use it for testing the Arc implementation.

  9. apasel422 commented on Nov 1, 2015

    @apasel422
    Contributor

    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 error
    
  10. pmarcelll commented on Mar 5, 2017

    @pmarcelll
    Contributor

    Related to #39699.

  11. added
    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.
    and removed
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    on Jul 19, 2017
  12. steveklabnik commented on Sep 24, 2018

    @steveklabnik
    Contributor

    Triage: #39699 is a duplicate and has more up-to-date info.

    RIP one of rustc's last four digit issues. <3

  13. added a commit that references this issue on Jun 4, 2024
  14. added a commit that references this issue on Nov 2, 2025
  15. added 2 commits that reference this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-concurrencyArea: ConcurrencyA-sanitizersArea: Sanitizers for correctness and code qualityA-testsuiteArea: The testsuite used to check the correctness of rustcC-feature-requestCategory: A feature request, i.e: not implemented / a PR.P-lowLow priority

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions