Skip to content

ThreadSanitizer detects a data race in the test runner (rustc --test) #39608

New issue

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

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

Already on GitHub? # to your account

Closed
japaric opened this issue Feb 7, 2017 · 5 comments · Fixed by #65097
Closed

ThreadSanitizer detects a data race in the test runner (rustc --test) #39608

japaric opened this issue Feb 7, 2017 · 5 comments · Fixed by #65097
Labels
A-libtest Area: `#[test]` / the `test` library A-sanitizers Area: Sanitizers for correctness and code quality C-bug Category: This is a bug.

Comments

@japaric
Copy link
Member

japaric commented Feb 7, 2017

iff the crate contains two or more unit tests.

STR

$ cargo new --lib test-runner && cd $_

$ edit src/lib.rs && cat $_
#[test]
fn foo() {}

#[test]
fn bar() {}
$ RUSTFLAGS="-Z sanitizer=thread" cargo test --target x86_64-unknown-linux-gnu                                                                                                                                   <<<
     Running target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235

running 2 tests
test bar ... ok
test foo ... ok
==================
WARNING: ThreadSanitizer: data race (pid=30969)
  Write of size 8 at 0x7c4c0000ed90 by thread T2:
    #0 free $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:634 (test_runner-d861d6557762b235+0x0000000ce207)
    #1 __rust_deallocate <null> (test_runner-d861d6557762b235+0x000000155663)
    #2 _$LT$alloc..arc..Arc$LT$T$GT$$GT$::drop_slow::hffd2bcc3b04fe791 <null> (test_runner-d861d6557762b235+0x00000001b835)
    #3 _$LT$alloc..arc..Arc$LT$T$GT$$GT$::drop_slow::hffd2bcc3b04fe791 <null> (test_runner-d861d6557762b235+0x00000001b835)
    #4 drop::h62528215215ec760 <null> (test_runner-d861d6557762b235+0x000000029a65)
    #5 drop::h62528215215ec760 <null> (test_runner-d861d6557762b235+0x000000029a65)
    #6 _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::he23b8085b7ff608a <null> (test_runner-d861d6557762b235+0x00000002dc34)
    #7 _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::he23b8085b7ff608a <null> (test_runner-d861d6557762b235+0x00000002dc34)
    #8 std::sys::imp::thread::Thread::new::thread_start::hee5c0f50902195ab <null> (test_runner-d861d6557762b235+0x0000000bcacc)
    #9 std::sys::imp::thread::Thread::new::thread_start::hee5c0f50902195ab <null> (test_runner-d861d6557762b235+0x0000000bcacc)
    #10 __tsan_thread_start_func $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:892 (test_runner-d861d6557762b235+0x0000000caf0b)
    #11 __tsan_thread_start_func $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:892 (test_runner-d861d6557762b235+0x0000000caf0b)

  Previous atomic write of size 8 at 0x7c4c0000ed90 by main thread:
    #0 __tsan_atomic64_fetch_sub $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:623 (test_runner-d861d6557762b235+0x0000001131b0)
    #1 drop::h62528215215ec760 <null> (test_runner-d861d6557762b235+0x000000029a33)
    #2 drop::h26c9032b0f649bf6 <null> (test_runner-d861d6557762b235+0x0000000288fd)
    #3 drop::h26c9032b0f649bf6 <null> (test_runner-d861d6557762b235+0x0000000288fd)
    #4 drop::h26c9032b0f649bf6 <null> (test_runner-d861d6557762b235+0x0000000288fd)
    #5 drop::h26c9032b0f649bf6 <null> (test_runner-d861d6557762b235+0x0000000288fd)
    #6 test::run_test::run_test_inner::h68ccb59ad7634829 <null> (test_runner-d861d6557762b235+0x000000060f65)
    #7 test::run_test::run_test_inner::h68ccb59ad7634829 <null> (test_runner-d861d6557762b235+0x000000060f65)
    #8 test::run_test::run_test_inner::h68ccb59ad7634829 <null> (test_runner-d861d6557762b235+0x000000060f65)
    #9 test::run_test::hbe43efe8762b5fcb <null> (test_runner-d861d6557762b235+0x00000005f4bd)
    #10 test::run_tests::h007db7d7a30e05b9 <null> (test_runner-d861d6557762b235+0x000000054a4a)
    #11 test::run_tests_console::h51b8f804fcc03777 <null> (test_runner-d861d6557762b235+0x00000004db4c)
    #12 test::test_main::h30f1de6986f689a9 <null> (test_runner-d861d6557762b235+0x0000000429d0)
    #13 test::test_main_static::h2d9326de74ff96ef <null> (test_runner-d861d6557762b235+0x000000043fe3)
    #14 test_runner::__test::main::h164d7dfa966cbb3f $PWD/src/lib.rs:1 (test_runner-d861d6557762b235+0x000000011362)
    #15 std::panicking::try::do_call::hb1cd11518796216e <null> (test_runner-d861d6557762b235+0x0000000be876)
    #16 __rust_maybe_catch_panic <null> (test_runner-d861d6557762b235+0x0000000c2363)
    #17 __rust_maybe_catch_panic <null> (test_runner-d861d6557762b235+0x0000000c2363)
    #18 std::rt::lang_start::h0661a76cd511ea2d <null> (test_runner-d861d6557762b235+0x0000000c0487)
    #19 std::rt::lang_start::h0661a76cd511ea2d <null> (test_runner-d861d6557762b235+0x0000000c0487)
    #20 main <null> (test_runner-d861d6557762b235+0x0000000113b7)
    #21 main <null> (test_runner-d861d6557762b235+0x0000000113b7)
    #22 main <null> (test_runner-d861d6557762b235+0x0000000113b7)

  Thread T2 'foo' (tid=30972, running) created by main thread at:
    #0 pthread_create $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:902 (test_runner-d861d6557762b235+0x0000000cf546)
    #1 std::sys::imp::thread::Thread::new::h59257a01c2b82abe <null> (test_runner-d861d6557762b235+0x0000000bc1ea)
    #2 test::run_test::run_test_inner::h68ccb59ad7634829 <null> (test_runner-d861d6557762b235+0x000000060cd2)
    #3 test::run_test::hbe43efe8762b5fcb <null> (test_runner-d861d6557762b235+0x00000005f4bd)
    #4 test::run_test::hbe43efe8762b5fcb <null> (test_runner-d861d6557762b235+0x00000005f4bd)
    #5 test::run_tests::h007db7d7a30e05b9 <null> (test_runner-d861d6557762b235+0x000000054a4a)
    #6 test::run_tests_console::h51b8f804fcc03777 <null> (test_runner-d861d6557762b235+0x00000004db4c)
    #7 test::test_main::h30f1de6986f689a9 <null> (test_runner-d861d6557762b235+0x0000000429d0)
    #8 test::test_main_static::h2d9326de74ff96ef <null> (test_runner-d861d6557762b235+0x000000043fe3)
    #9 test_runner::__test::main::h164d7dfa966cbb3f $PWD/src/lib.rs:1 (test_runner-d861d6557762b235+0x000000011362)
    #10 std::panicking::try::do_call::hb1cd11518796216e <null> (test_runner-d861d6557762b235+0x0000000be876)
    #11 __rust_maybe_catch_panic <null> (test_runner-d861d6557762b235+0x0000000c2363)
    #12 __rust_maybe_catch_panic <null> (test_runner-d861d6557762b235+0x0000000c2363)
    #13 std::rt::lang_start::h0661a76cd511ea2d <null> (test_runner-d861d6557762b235+0x0000000c0487)
    #14 std::rt::lang_start::h0661a76cd511ea2d <null> (test_runner-d861d6557762b235+0x0000000c0487)
    #15 main <null> (test_runner-d861d6557762b235+0x0000000113b7)
    #16 main <null> (test_runner-d861d6557762b235+0x0000000113b7)
    #17 main <null> (test_runner-d861d6557762b235+0x0000000113b7)

SUMMARY: ThreadSanitizer: data race ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0x155663) in __rust_deallocate
==================
==================
WARNING: ThreadSanitizer: data race (pid=30969)
  Write of size 8 at 0x7c580000ef40 by main thread:
    #0 free $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:634 (test_runner-d861d6557762b235+0x0000000ce207)
    #1 __rust_deallocate <null> (test_runner-d861d6557762b235+0x000000155663)
    #2 _$LT$alloc..arc..Arc$LT$T$GT$$GT$::drop_slow::hc07f22e2b818fd5e <null> (test_runner-d861d6557762b235+0x00000001b234)
    #3 _$LT$alloc..arc..Arc$LT$T$GT$$GT$::drop_slow::hc07f22e2b818fd5e <null> (test_runner-d861d6557762b235+0x00000001b234)
    #4 drop::hd5322f45aa23e49d <null> (test_runner-d861d6557762b235+0x00000002c005)
    #5 drop::hd5322f45aa23e49d <null> (test_runner-d861d6557762b235+0x00000002c005)
    #6 drop::hb2fbb6e76af21657 <null> (test_runner-d861d6557762b235+0x00000002b98e)
    #7 drop::hb2fbb6e76af21657 <null> (test_runner-d861d6557762b235+0x00000002b98e)
    #8 drop::ha932b14572fc49af <null> (test_runner-d861d6557762b235+0x00000002ae22)
    #9 test::run_tests::h007db7d7a30e05b9 <null> (test_runner-d861d6557762b235+0x0000000588b1)
    #10 test::run_tests::h007db7d7a30e05b9 <null> (test_runner-d861d6557762b235+0x0000000588b1)
    #11 test::run_tests::h007db7d7a30e05b9 <null> (test_runner-d861d6557762b235+0x0000000588b1)
    #12 test::run_tests_console::h51b8f804fcc03777 <null> (test_runner-d861d6557762b235+0x00000004db4c)
    #13 test::test_main::h30f1de6986f689a9 <null> (test_runner-d861d6557762b235+0x0000000429d0)
    #14 test::test_main_static::h2d9326de74ff96ef <null> (test_runner-d861d6557762b235+0x000000043fe3)
    #15 test_runner::__test::main::h164d7dfa966cbb3f $PWD/src/lib.rs:1 (test_runner-d861d6557762b235+0x000000011362)
    #16 std::panicking::try::do_call::hb1cd11518796216e <null> (test_runner-d861d6557762b235+0x0000000be876)
    #17 __rust_maybe_catch_panic <null> (test_runner-d861d6557762b235+0x0000000c2363)
    #18 __rust_maybe_catch_panic <null> (test_runner-d861d6557762b235+0x0000000c2363)
    #19 std::rt::lang_start::h0661a76cd511ea2d <null> (test_runner-d861d6557762b235+0x0000000c0487)
    #20 std::rt::lang_start::h0661a76cd511ea2d <null> (test_runner-d861d6557762b235+0x0000000c0487)
    #21 main <null> (test_runner-d861d6557762b235+0x0000000113b7)
    #22 main <null> (test_runner-d861d6557762b235+0x0000000113b7)
    #23 main <null> (test_runner-d861d6557762b235+0x0000000113b7)

  Previous atomic write of size 8 at 0x7c580000ef40 by thread T2:
    #0 __tsan_atomic64_fetch_sub $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:623 (test_runner-d861d6557762b235+0x0000001131b0)
    #1 drop::hd5322f45aa23e49d <null> (test_runner-d861d6557762b235+0x00000002bfd3)
    #2 drop::hb2fbb6e76af21657 <null> (test_runner-d861d6557762b235+0x00000002b98e)
    #3 drop::hb2fbb6e76af21657 <null> (test_runner-d861d6557762b235+0x00000002b98e)
    #4 drop::hb2fbb6e76af21657 <null> (test_runner-d861d6557762b235+0x00000002b98e)
    #5 drop::hb2fbb6e76af21657 <null> (test_runner-d861d6557762b235+0x00000002b98e)
    #6 drop::ha932b14572fc49af <null> (test_runner-d861d6557762b235+0x00000002ae22)
    #7 std::panicking::try::do_call::heac7d42b6d137ab0 <null> (test_runner-d861d6557762b235+0x00000001e7a7)
    #8 std::panicking::try::do_call::heac7d42b6d137ab0 <null> (test_runner-d861d6557762b235+0x00000001e7a7)
    #9 std::panicking::try::do_call::heac7d42b6d137ab0 <null> (test_runner-d861d6557762b235+0x00000001e7a7)
    #10 __rust_maybe_catch_panic <null> (test_runner-d861d6557762b235+0x0000000c2363)
    #11 __rust_maybe_catch_panic <null> (test_runner-d861d6557762b235+0x0000000c2363)
    #12 __rust_maybe_catch_panic <null> (test_runner-d861d6557762b235+0x0000000c2363)
    #13 _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::he23b8085b7ff608a <null> (test_runner-d861d6557762b235+0x00000002db21)
    #14 _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::he23b8085b7ff608a <null> (test_runner-d861d6557762b235+0x00000002db21)
    #15 std::sys::imp::thread::Thread::new::thread_start::hee5c0f50902195ab <null> (test_runner-d861d6557762b235+0x0000000bcacc)
    #16 std::sys::imp::thread::Thread::new::thread_start::hee5c0f50902195ab <null> (test_runner-d861d6557762b235+0x0000000bcacc)
    #17 std::sys::imp::thread::Thread::new::thread_start::hee5c0f50902195ab <null> (test_runner-d861d6557762b235+0x0000000bcacc)
    #18 std::sys::imp::thread::Thread::new::thread_start::hee5c0f50902195ab <null> (test_runner-d861d6557762b235+0x0000000bcacc)
    #19 __tsan_thread_start_func $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:892 (test_runner-d861d6557762b235+0x0000000caf0b)
    #20 __tsan_thread_start_func $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:892 (test_runner-d861d6557762b235+0x0000000caf0b)

  Thread T2 'foo' (tid=30972, running) created by main thread at:
    #0 pthread_create $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:902 (test_runner-d861d6557762b235+0x0000000cf546)
    #1 std::sys::imp::thread::Thread::new::h59257a01c2b82abe <null> (test_runner-d861d6557762b235+0x0000000bc1ea)
    #2 test::run_test::run_test_inner::h68ccb59ad7634829 <null> (test_runner-d861d6557762b235+0x000000060cd2)
    #3 test::run_test::hbe43efe8762b5fcb <null> (test_runner-d861d6557762b235+0x00000005f4bd)
    #4 test::run_test::hbe43efe8762b5fcb <null> (test_runner-d861d6557762b235+0x00000005f4bd)
    #5 test::run_tests::h007db7d7a30e05b9 <null> (test_runner-d861d6557762b235+0x000000054a4a)
    #6 test::run_tests_console::h51b8f804fcc03777 <null> (test_runner-d861d6557762b235+0x00000004db4c)
    #7 test::test_main::h30f1de6986f689a9 <null> (test_runner-d861d6557762b235+0x0000000429d0)
    #8 test::test_main_static::h2d9326de74ff96ef <null> (test_runner-d861d6557762b235+0x000000043fe3)
    #9 test_runner::__test::main::h164d7dfa966cbb3f $PWD/src/lib.rs:1 (test_runner-d861d6557762b235+0x000000011362)
    #10 std::panicking::try::do_call::hb1cd11518796216e <null> (test_runner-d861d6557762b235+0x0000000be876)
    #11 __rust_maybe_catch_panic <null> (test_runner-d861d6557762b235+0x0000000c2363)
    #12 __rust_maybe_catch_panic <null> (test_runner-d861d6557762b235+0x0000000c2363)
    #13 std::rt::lang_start::h0661a76cd511ea2d <null> (test_runner-d861d6557762b235+0x0000000c0487)
    #14 std::rt::lang_start::h0661a76cd511ea2d <null> (test_runner-d861d6557762b235+0x0000000c0487)
    #15 main <null> (test_runner-d861d6557762b235+0x0000000113b7)
    #16 main <null> (test_runner-d861d6557762b235+0x0000000113b7)
    #17 main <null> (test_runner-d861d6557762b235+0x0000000113b7)

SUMMARY: ThreadSanitizer: data race ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0x155663) in __rust_deallocate
==================

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured

==================
WARNING: ThreadSanitizer: data race (pid=30969)
  Write of size 8 at 0x7c540000ef60 by thread T2:
    #0 free $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:634 (test_runner-d861d6557762b235+0x0000000ce207)
    #1 __rust_deallocate <null> (test_runner-d861d6557762b235+0x000000155663)
    #2 _$LT$alloc..arc..Arc$LT$T$GT$$GT$::drop_slow::hff346d8fec1237f8 <null> (test_runner-d861d6557762b235+0x00000009fbc4)
    #3 _$LT$alloc..arc..Arc$LT$T$GT$$GT$::drop_slow::hff346d8fec1237f8 <null> (test_runner-d861d6557762b235+0x00000009fbc4)
    #4 drop::h5f9d93ca09665cd2 <null> (test_runner-d861d6557762b235+0x0000000a395d)
    #5 drop::h5f9d93ca09665cd2 <null> (test_runner-d861d6557762b235+0x0000000a395d)
    #6 drop::h1a3c63fc24632ae0 <null> (test_runner-d861d6557762b235+0x0000000a34bf)
    #7 drop::h1a3c63fc24632ae0 <null> (test_runner-d861d6557762b235+0x0000000a34bf)
    #8 drop::h1a3c63fc24632ae0 <null> (test_runner-d861d6557762b235+0x0000000a34bf)
    #9 std::sys::imp::fast_thread_local::destroy_value::hd0a16359cb28bafd <null> (test_runner-d861d6557762b235+0x0000000b9518)
    #10 std::sys::imp::fast_thread_local::destroy_value::hd0a16359cb28bafd <null> (test_runner-d861d6557762b235+0x0000000b9518)
    #11 std::sys::imp::fast_thread_local::destroy_value::hd0a16359cb28bafd <null> (test_runner-d861d6557762b235+0x0000000b9518)
    #12 __GI___call_tls_dtors <null> (libc.so.6+0x000000035efe)
    #13 __GI___call_tls_dtors <null> (libc.so.6+0x000000035efe)
    #14 __GI___call_tls_dtors <null> (libc.so.6+0x000000035efe)

  Previous atomic write of size 8 at 0x7c540000ef60 by main thread:
    #0 __tsan_atomic64_fetch_sub $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:623 (test_runner-d861d6557762b235+0x0000001131b0)
    #1 drop::h76fdafd6e6eb83b7 <null> (test_runner-d861d6557762b235+0x00000002a0fb)
    #2 drop::h26c9032b0f649bf6 <null> (test_runner-d861d6557762b235+0x0000000288e9)
    #3 drop::h26c9032b0f649bf6 <null> (test_runner-d861d6557762b235+0x0000000288e9)
    #4 drop::h26c9032b0f649bf6 <null> (test_runner-d861d6557762b235+0x0000000288e9)
    #5 drop::h26c9032b0f649bf6 <null> (test_runner-d861d6557762b235+0x0000000288e9)
    #6 drop::h26c9032b0f649bf6 <null> (test_runner-d861d6557762b235+0x0000000288e9)
    #7 test::run_test::run_test_inner::h68ccb59ad7634829 <null> (test_runner-d861d6557762b235+0x000000060f65)
    #8 test::run_test::run_test_inner::h68ccb59ad7634829 <null> (test_runner-d861d6557762b235+0x000000060f65)
    #9 test::run_test::hbe43efe8762b5fcb <null> (test_runner-d861d6557762b235+0x00000005f4bd)
    #10 test::run_tests::h007db7d7a30e05b9 <null> (test_runner-d861d6557762b235+0x000000054a4a)
    #11 test::run_tests_console::h51b8f804fcc03777 <null> (test_runner-d861d6557762b235+0x00000004db4c)
    #12 test::test_main::h30f1de6986f689a9 <null> (test_runner-d861d6557762b235+0x0000000429d0)
    #13 test::test_main_static::h2d9326de74ff96ef <null> (test_runner-d861d6557762b235+0x000000043fe3)
    #14 test_runner::__test::main::h164d7dfa966cbb3f $PWD/src/lib.rs:1 (test_runner-d861d6557762b235+0x000000011362)
    #15 std::panicking::try::do_call::hb1cd11518796216e <null> (test_runner-d861d6557762b235+0x0000000be876)
    #16 __rust_maybe_catch_panic <null> (test_runner-d861d6557762b235+0x0000000c2363)
    #17 __rust_maybe_catch_panic <null> (test_runner-d861d6557762b235+0x0000000c2363)
    #18 std::rt::lang_start::h0661a76cd511ea2d <null> (test_runner-d861d6557762b235+0x0000000c0487)
    #19 std::rt::lang_start::h0661a76cd511ea2d <null> (test_runner-d861d6557762b235+0x0000000c0487)
    #20 main <null> (test_runner-d861d6557762b235+0x0000000113b7)
    #21 main <null> (test_runner-d861d6557762b235+0x0000000113b7)
    #22 main <null> (test_runner-d861d6557762b235+0x0000000113b7)

  Thread T2 'foo' (tid=30972, running) created by main thread at:
    #0 pthread_create $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:902 (test_runner-d861d6557762b235+0x0000000cf546)
    #1 std::sys::imp::thread::Thread::new::h59257a01c2b82abe <null> (test_runner-d861d6557762b235+0x0000000bc1ea)
    #2 test::run_test::run_test_inner::h68ccb59ad7634829 <null> (test_runner-d861d6557762b235+0x000000060cd2)
    #3 test::run_test::hbe43efe8762b5fcb <null> (test_runner-d861d6557762b235+0x00000005f4bd)
    #4 test::run_test::hbe43efe8762b5fcb <null> (test_runner-d861d6557762b235+0x00000005f4bd)
    #5 test::run_tests::h007db7d7a30e05b9 <null> (test_runner-d861d6557762b235+0x000000054a4a)
    #6 test::run_tests_console::h51b8f804fcc03777 <null> (test_runner-d861d6557762b235+0x00000004db4c)
    #7 test::test_main::h30f1de6986f689a9 <null> (test_runner-d861d6557762b235+0x0000000429d0)
    #8 test::test_main_static::h2d9326de74ff96ef <null> (test_runner-d861d6557762b235+0x000000043fe3)
    #9 test_runner::__test::main::h164d7dfa966cbb3f $PWD/src/lib.rs:1 (test_runner-d861d6557762b235+0x000000011362)
    #10 std::panicking::try::do_call::hb1cd11518796216e <null> (test_runner-d861d6557762b235+0x0000000be876)
    #11 __rust_maybe_catch_panic <null> (test_runner-d861d6557762b235+0x0000000c2363)
    #12 __rust_maybe_catch_panic <null> (test_runner-d861d6557762b235+0x0000000c2363)
    #13 std::rt::lang_start::h0661a76cd511ea2d <null> (test_runner-d861d6557762b235+0x0000000c0487)
    #14 std::rt::lang_start::h0661a76cd511ea2d <null> (test_runner-d861d6557762b235+0x0000000c0487)
    #15 main <null> (test_runner-d861d6557762b235+0x0000000113b7)
    #16 main <null> (test_runner-d861d6557762b235+0x0000000113b7)
    #17 main <null> (test_runner-d861d6557762b235+0x0000000113b7)

SUMMARY: ThreadSanitizer: data race ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0x155663) in __rust_deallocate
==================
ThreadSanitizer: reported 3 warnings
error: test failed

Meta

TODO Sanitizers are not yet in tree. (cf. #38699)


cc @alexcrichton @brson

@alexcrichton
Copy link
Member

Like with #39610 I'd be tempted to say these are false positives, but these stack traces don't look so familiar so I'm not certain of that

@parched
Copy link
Contributor

parched commented Feb 8, 2017

This will be a false positive because drop_slow uses a fence, and tsan doesn't work with fences.

@Mark-Simulacrum
Copy link
Member

So I take it this isn't actually a problem since we're just using a fence and tsan doesn't support that? Should we close?

@kennytm
Copy link
Member

kennytm commented May 22, 2017

Can the false-positive be worked-around by manually annotating the happens-before relationship? See https://stackoverflow.com/questions/37552866/why-does-threadsanitizer-report-a-race-with-this-lock-free-example.

@parched
Copy link
Contributor

parched commented May 22, 2017

Well, maybe if we could conditionally build without the fence (rework to use a load/store instead) when tsan is enabled then the error wouldn't be seen.

@Mark-Simulacrum Mark-Simulacrum added A-libtest Area: `#[test]` / the `test` library A-sanitizers Area: Sanitizers for correctness and code quality labels Jun 23, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 27, 2017
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Mar 20, 2020
Make std::sync::Arc compatible with ThreadSanitizer

The memory fences used previously in Arc implementation are not properly
understood by thread sanitizer as synchronization primitives. This had
unfortunate effect where running any non-trivial program compiled with
`-Z sanitizer=thread` would result in numerous false positives.

Replace acquire fences with acquire loads to address the issue.

Fixes rust-lang#39608.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Mar 21, 2020
Make std::sync::Arc compatible with ThreadSanitizer

The memory fences used previously in Arc implementation are not properly
understood by thread sanitizer as synchronization primitives. This had
unfortunate effect where running any non-trivial program compiled with
`-Z sanitizer=thread` would result in numerous false positives.

Replace acquire fences with acquire loads to address the issue.

Fixes rust-lang#39608.
Centril added a commit to Centril/rust that referenced this issue Mar 21, 2020
Make std::sync::Arc compatible with ThreadSanitizer

The memory fences used previously in Arc implementation are not properly
understood by thread sanitizer as synchronization primitives. This had
unfortunate effect where running any non-trivial program compiled with
`-Z sanitizer=thread` would result in numerous false positives.

Replace acquire fences with acquire loads to address the issue.

Fixes rust-lang#39608.
@bors bors closed this as completed in 4b91729 Mar 21, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-libtest Area: `#[test]` / the `test` library A-sanitizers Area: Sanitizers for correctness and code quality C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants