vorner / arc-swap

Support atomic operations on Arc itself

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Data race reported by thread sanitizer

NobodyXu opened this issue · comments

I tried to run the tests of arc-swap using thread sanitizer using command RUSTFLAGS='-Zsanitizer=thread' cargo +nightly test -Z build-std --target --target $(uname -m)-unknown-linux-gnu and it reported data race when dropping the Arc in tests_default::rcu:

    Finished test [unoptimized + debuginfo] target(s) in 0.04s
     Running unittests (target/x86_64-unknown-linux-gnu/debug/deps/arc_swap-a1768ea5572bf654)

running 32 tests
test access::tests::constant ... ok
test access::tests::dyn_dispatch ... ok
test access::tests::indirect ... ok
test access::tests::map ... ok
test access::tests::map_option_none ... ok
test access::tests::map_option_some ... ok
test access::tests::map_reload ... ok
test access::tests::static_dispatch ... ok
test access::tests::transition ... ok
test cache::tests::cache_option ... ok
test cache::tests::cached_through_arc ... ok
test cache::tests::cached_value ... ok
test cache::tests::map_cache ... ok
test debt::list::tests::new_empty ... ok
test debt::tests::arc_zst ... ok
test tests::load_cnt ... ok
test tests_default::debug_impl ... ok
test tests_default::display_impl ... ok
test tests_default::from_into ... ok
error: address range table at offset 0xb360 has a premature terminator entry at offset 0xb370
==================
WARNING: ThreadSanitizer: data race (pid=4450)
  Write of size 8 at 0x7b0800011070 by thread T40:
    #0 free /rustc/llvm/src/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:714:3 (arc_swap-a1768ea5572bf654+0x2b01a)
    #1 std::sys::unix::alloc::_$LT$impl$u20$core..alloc..global..GlobalAlloc$u20$for$u20$std..alloc..System$GT$::dealloc::h2a676766609ecfae /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/alloc.rs:42:9 (arc_swap-a1768ea5572bf654+0x2a2bdf)
    #2 __rdl_dealloc /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/alloc.rs:363:18 (arc_swap-a1768ea5572bf654+0x2a13a6)
    #3 alloc::alloc::dealloc::h7dd58574c00b6e12 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:105:14 (arc_swap-a1768ea5572bf654+0x104835)
    #4 _$LT$alloc..alloc..Global$u20$as$u20$core..alloc..Allocator$GT$::deallocate::h80b64e023ec403c3 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:242:22 (arc_swap-a1768ea5572bf654+0x1048fc)
    #5 _$LT$alloc..sync..Weak$LT$T$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::h972ab532e7a56912 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:2112:22 (arc_swap-a1768ea5572bf654+0xc0058)
    #6 core::ptr::drop_in_place$LT$alloc..sync..Weak$LT$usize$GT$$GT$::h14cdda59bb6ae4c5 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:188:1 (arc_swap-a1768ea5572bf654+0xbd151)
    #7 core::mem::drop::hcbdebd2938104196 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/mod.rs:909:24 (arc_swap-a1768ea5572bf654+0xcc035)
    #8 alloc::sync::Arc$LT$T$GT$::drop_slow::h79326a6c2d7f5f6e /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:1082:9 (arc_swap-a1768ea5572bf654+0x125fd8)
    #9 _$LT$alloc..sync..Arc$LT$T$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::h5aa682a3552dcc7a /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:1640:13 (arc_swap-a1768ea5572bf654+0xbebd6)
    #10 core::ptr::drop_in_place$LT$alloc..sync..Arc$LT$usize$GT$$GT$::h5329865589d3d4c5 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:188:1 (arc_swap-a1768ea5572bf654+0xbd101)
    #11 arc_swap::tests_default::rcu::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::hab228751d993e96f /home/nobodyxu/Dev/arc-swap/src/lib.rs:1151:60 (arc_swap-a1768ea5572bf654+0xca953)
    #12 crossbeam_utils::thread::ScopedThreadBuilder::spawn::_$u7b$$u7b$closure$u7d$$u7d$::hd1a628fb4539dce5 /home/nobodyxu/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.1/src/thread.rs:439:31 (arc_swap-a1768ea5572bf654+0xdbfeb)
    #13 core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h3ade10cc6f2cda4d /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 (arc_swap-a1768ea5572bf654+0xb86c1)
    #14 _$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..FnOnce$LT$Args$GT$$GT$::call_once::hf6de0726e1706af5 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1811:9 (arc_swap-a1768ea5572bf654+0x1c5494)
    #15 crossbeam_utils::thread::ScopedThreadBuilder::spawn::_$u7b$$u7b$closure$u7d$$u7d$::hc3d74a0446b1f962 /home/nobodyxu/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.1/src/thread.rs:451:44 (arc_swap-a1768ea5572bf654+0xdbf34)
    #16 std::sys_common::backtrace::__rust_begin_short_backtrace::h6203e4b1e4897b64 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:123:18 (arc_swap-a1768ea5572bf654+0x114df0)
    #17 std::thread::Builder::spawn_unchecked::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::hbd7e468265a15286 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:477:17 (arc_swap-a1768ea5572bf654+0x100b10)
    #18 _$LT$core..panic..unwind_safe..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::h09abfc3b272fa102 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:271:9 (arc_swap-a1768ea5572bf654+0xf3760)
    #19 std::panicking::try::do_call::he1640aa9f23227b8 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:406:40 (arc_swap-a1768ea5572bf654+0xf5f3a)
    #20 __rust_try 46q4l7863lajlfyb (arc_swap-a1768ea5572bf654+0xf6fe8)
    #21 std::panicking::try::he36d6e9452d5f899 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:370:19 (arc_swap-a1768ea5572bf654+0xf5792)
    #22 std::panic::catch_unwind::hed3158c9c5021004 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:133:14 (arc_swap-a1768ea5572bf654+0x10aad0)
    #23 std::thread::Builder::spawn_unchecked::_$u7b$$u7b$closure$u7d$$u7d$::hcc61b96682cb1896 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:476:30 (arc_swap-a1768ea5572bf654+0x100185)
    #24 core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h963922abc48f8173 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 (arc_swap-a1768ea5572bf654+0xb8951)
    #25 _$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..FnOnce$LT$Args$GT$$GT$::call_once::h7c51f785c4bdd214 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1811:9 (arc_swap-a1768ea5572bf654+0x388074)
    #26 _$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..FnOnce$LT$Args$GT$$GT$::call_once::hbbe111351615a74a /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1811:9 (arc_swap-a1768ea5572bf654+0x38814e)
    #27 std::sys::unix::thread::Thread::new::thread_start::he6142c0fcd17dea0 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/thread.rs:108:17 (arc_swap-a1768ea5572bf654+0x2d4ae1)

  Previous read of size 8 at 0x7b0800011070 by thread T41:
    #0 arc_swap::tests_default::rcu::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::hb9750c6dcef40c7c /home/nobodyxu/Dev/arc-swap/src/lib.rs:1151:50 (arc_swap-a1768ea5572bf654+0xca803)
    #1 arc_swap::ArcSwapAny$LT$T$C$S$GT$::rcu::h734005388dc8f10f /home/nobodyxu/Dev/arc-swap/src/lib.rs:600:23 (arc_swap-a1768ea5572bf654+0xe9542)
    #2 arc_swap::tests_default::rcu::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::hab228751d993e96f /home/nobodyxu/Dev/arc-swap/src/lib.rs:1151:33 (arc_swap-a1768ea5572bf654+0xca92e)
    #3 crossbeam_utils::thread::ScopedThreadBuilder::spawn::_$u7b$$u7b$closure$u7d$$u7d$::hd1a628fb4539dce5 /home/nobodyxu/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.1/src/thread.rs:439:31 (arc_swap-a1768ea5572bf654+0xdbfeb)
    #4 core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h3ade10cc6f2cda4d /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 (arc_swap-a1768ea5572bf654+0xb86c1)
    #5 _$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..FnOnce$LT$Args$GT$$GT$::call_once::hf6de0726e1706af5 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1811:9 (arc_swap-a1768ea5572bf654+0x1c5494)
    #6 crossbeam_utils::thread::ScopedThreadBuilder::spawn::_$u7b$$u7b$closure$u7d$$u7d$::hc3d74a0446b1f962 /home/nobodyxu/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.1/src/thread.rs:451:44 (arc_swap-a1768ea5572bf654+0xdbf34)
    #7 std::sys_common::backtrace::__rust_begin_short_backtrace::h6203e4b1e4897b64 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:123:18 (arc_swap-a1768ea5572bf654+0x114df0)
    #8 std::thread::Builder::spawn_unchecked::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::hbd7e468265a15286 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:477:17 (arc_swap-a1768ea5572bf654+0x100b10)
    #9 _$LT$core..panic..unwind_safe..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::h09abfc3b272fa102 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:271:9 (arc_swap-a1768ea5572bf654+0xf3760)
    #10 std::panicking::try::do_call::he1640aa9f23227b8 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:406:40 (arc_swap-a1768ea5572bf654+0xf5f3a)
    #11 __rust_try 46q4l7863lajlfyb (arc_swap-a1768ea5572bf654+0xf6fe8)
    #12 std::panicking::try::he36d6e9452d5f899 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:370:19 (arc_swap-a1768ea5572bf654+0xf5792)
    #13 std::panic::catch_unwind::hed3158c9c5021004 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:133:14 (arc_swap-a1768ea5572bf654+0x10aad0)
    #14 std::thread::Builder::spawn_unchecked::_$u7b$$u7b$closure$u7d$$u7d$::hcc61b96682cb1896 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:476:30 (arc_swap-a1768ea5572bf654+0x100185)
    #15 core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h963922abc48f8173 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 (arc_swap-a1768ea5572bf654+0xb8951)
    #16 _$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..FnOnce$LT$Args$GT$$GT$::call_once::h7c51f785c4bdd214 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1811:9 (arc_swap-a1768ea5572bf654+0x388074)
    #17 _$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..FnOnce$LT$Args$GT$$GT$::call_once::hbbe111351615a74a /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1811:9 (arc_swap-a1768ea5572bf654+0x38814e)
    #18 std::sys::unix::thread::Thread::new::thread_start::he6142c0fcd17dea0 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/thread.rs:108:17 (arc_swap-a1768ea5572bf654+0x2d4ae1)

  Thread T40 (tid=4506, running) created by thread T36 at:
    #0 pthread_create /rustc/llvm/src/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:977:3 (arc_swap-a1768ea5572bf654+0x2be0d)
    #1 std::sys::unix::thread::Thread::new::h2b5a08657dc2c320 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/thread.rs:87:19 (arc_swap-a1768ea5572bf654+0x2d450e)
    #2 std::thread::Builder::spawn_unchecked::hc317474f05d4028d /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:501:22 (arc_swap-a1768ea5572bf654+0xfe129)
    #3 std::thread::Builder::spawn::h72094c6f68d6ddf9 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:382:18 (arc_swap-a1768ea5572bf654+0x100d6c)
    #4 crossbeam_utils::thread::ScopedThreadBuilder::spawn::hceed5dcfd21efa90 /home/nobodyxu/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.1/src/thread.rs:451:17 (arc_swap-a1768ea5572bf654+0xd951a)
    #5 crossbeam_utils::thread::Scope::spawn::h66ed5f14db304999 /home/nobodyxu/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.1/src/thread.rs:253:9 (arc_swap-a1768ea5572bf654+0xdc63d)
    #6 arc_swap::tests_default::rcu::_$u7b$$u7b$closure$u7d$$u7d$::h140b87f7cb8908d8 /home/nobodyxu/Dev/arc-swap/src/lib.rs:1149:25 (arc_swap-a1768ea5572bf654+0xcaa5b)
    #7 crossbeam_utils::thread::scope::_$u7b$$u7b$closure$u7d$$u7d$::h5b70e2b63ccb0dc9 /home/nobodyxu/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.1/src/thread.rs:162:65 (arc_swap-a1768ea5572bf654+0xdf8aa)
    #8 _$LT$core..panic..unwind_safe..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::haee83a11e98b1ebc /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:271:9 (arc_swap-a1768ea5572bf654+0xf3b20)
    #9 std::panicking::try::do_call::h0a816b8087cdf13f /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:406:40 (arc_swap-a1768ea5572bf654+0xf5a0a)
    #10 __rust_try 46q4l7863lajlfyb (arc_swap-a1768ea5572bf654+0xf6fe8)
    #11 std::panicking::try::h9aa7612f6f5036b4 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:370:19 (arc_swap-a1768ea5572bf654+0xf5102)
    #12 std::panic::catch_unwind::hb1629b867c5b7d3b /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:133:14 (arc_swap-a1768ea5572bf654+0x10a9f0)
    #13 crossbeam_utils::thread::scope::hee133044b35ad8fd /home/nobodyxu/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.1/src/thread.rs:162:18 (arc_swap-a1768ea5572bf654+0xde55b)
    #14 arc_swap::tests_default::rcu::he018d1d919ddec6e /home/nobodyxu/Dev/arc-swap/src/lib.rs:1147:17 (arc_swap-a1768ea5572bf654+0xd22a4)
    #15 arc_swap::tests_default::rcu::_$u7b$$u7b$closure$u7d$$u7d$::h1c58c438b8b61300 /home/nobodyxu/Dev/arc-swap/src/lib.rs:1143:13 (arc_swap-a1768ea5572bf654+0xca791)
    #16 core::ops::function::FnOnce::call_once::h7c7a226754085154 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 (arc_swap-a1768ea5572bf654+0xb94e7)
    #17 core::ops::function::FnOnce::call_once::hb81219a3a5574e0d /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 (arc_swap-a1768ea5572bf654+0x1a094e)
    #18 test::__rust_begin_short_backtrace::hc71431af1903e77b /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:585:5 (arc_swap-a1768ea5572bf654+0x1de285)
    #19 test::run_test::_$u7b$$u7b$closure$u7d$$u7d$::hafa7836b79e6a84c /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:576:30 (arc_swap-a1768ea5572bf654+0x1dd121)
    #20 core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h702f3abbcdb74f00 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 (arc_swap-a1768ea5572bf654+0x19f92e)
    #21 _$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..FnOnce$LT$Args$GT$$GT$::call_once::hf6de0726e1706af5 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1811:9 (arc_swap-a1768ea5572bf654+0x1c5494)
    #22 _$LT$core..panic..unwind_safe..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::h887b5a540163d6ca /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:271:9 (arc_swap-a1768ea5572bf654+0x184cb4)
    #23 std::panicking::try::do_call::ha3f9f4ebee654392 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:406:40 (arc_swap-a1768ea5572bf654+0x186cd2)
    #24 __rust_try test.200d92bc-cgu.13 (arc_swap-a1768ea5572bf654+0x18f1d8)
    #25 std::panicking::try::hbb5d8a48518ef1b9 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:370:19 (arc_swap-a1768ea5572bf654+0x186942)
    #26 std::panic::catch_unwind::h2c3ba6136512c7a0 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:133:14 (arc_swap-a1768ea5572bf654+0x185124)
    #27 test::run_test_in_process::h382f64c350b24b5d /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:608:18 (arc_swap-a1768ea5572bf654+0x1de602)
    #28 test::run_test::run_test_inner::_$u7b$$u7b$closure$u7d$$u7d$::he81ffb33c672e6dd /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:500:39 (arc_swap-a1768ea5572bf654+0x1dded8)
    #29 test::run_test::run_test_inner::_$u7b$$u7b$closure$u7d$$u7d$::hd865da0c3a692927 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:527:37 (arc_swap-a1768ea5572bf654+0x1de12a)
    #30 std::sys_common::backtrace::__rust_begin_short_backtrace::he0d056c803c7b37c /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:123:18 (arc_swap-a1768ea5572bf654+0x184ff1)
    #31 std::thread::Builder::spawn_unchecked::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h5f5177097fcfe840 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:477:17 (arc_swap-a1768ea5572bf654+0x186225)
    #32 _$LT$core..panic..unwind_safe..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::hf2387297fea4c3a7 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:271:9 (arc_swap-a1768ea5572bf654+0x184de5)
    #33 std::panicking::try::do_call::h3321a8597b07e432 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:406:40 (arc_swap-a1768ea5572bf654+0x186a3e)
    #34 __rust_try test.200d92bc-cgu.13 (arc_swap-a1768ea5572bf654+0x18f1d8)
    #35 std::panicking::try::h7468cf75cc472c84 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:370:19 (arc_swap-a1768ea5572bf654+0x1867f6)
    #36 std::panic::catch_unwind::h7e598a4e380a1bd3 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:133:14 (arc_swap-a1768ea5572bf654+0x185185)
    #37 std::thread::Builder::spawn_unchecked::_$u7b$$u7b$closure$u7d$$u7d$::h379f61b76aa5aaa7 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:476:30 (arc_swap-a1768ea5572bf654+0x185f61)
    #38 core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h517dc5422141019f /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 (arc_swap-a1768ea5572bf654+0x19f8d5)
    #39 _$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..FnOnce$LT$Args$GT$$GT$::call_once::h7c51f785c4bdd214 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1811:9 (arc_swap-a1768ea5572bf654+0x388074)
    #40 _$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..FnOnce$LT$Args$GT$$GT$::call_once::hbbe111351615a74a /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1811:9 (arc_swap-a1768ea5572bf654+0x38814e)
    #41 std::sys::unix::thread::Thread::new::thread_start::he6142c0fcd17dea0 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/thread.rs:108:17 (arc_swap-a1768ea5572bf654+0x2d4ae1)

  Thread T41 (tid=4507, running) created by thread T36 at:
    #0 pthread_create /rustc/llvm/src/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:977:3 (arc_swap-a1768ea5572bf654+0x2be0d)
    #1 std::sys::unix::thread::Thread::new::h2b5a08657dc2c320 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/thread.rs:87:19 (arc_swap-a1768ea5572bf654+0x2d450e)
    #2 std::thread::Builder::spawn_unchecked::hc317474f05d4028d /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:501:22 (arc_swap-a1768ea5572bf654+0xfe129)
    #3 std::thread::Builder::spawn::h72094c6f68d6ddf9 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:382:18 (arc_swap-a1768ea5572bf654+0x100d6c)
    #4 crossbeam_utils::thread::ScopedThreadBuilder::spawn::hceed5dcfd21efa90 /home/nobodyxu/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.1/src/thread.rs:451:17 (arc_swap-a1768ea5572bf654+0xd951a)
    #5 crossbeam_utils::thread::Scope::spawn::h66ed5f14db304999 /home/nobodyxu/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.1/src/thread.rs:253:9 (arc_swap-a1768ea5572bf654+0xdc63d)
    #6 arc_swap::tests_default::rcu::_$u7b$$u7b$closure$u7d$$u7d$::h140b87f7cb8908d8 /home/nobodyxu/Dev/arc-swap/src/lib.rs:1149:25 (arc_swap-a1768ea5572bf654+0xcaa5b)
    #7 crossbeam_utils::thread::scope::_$u7b$$u7b$closure$u7d$$u7d$::h5b70e2b63ccb0dc9 /home/nobodyxu/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.1/src/thread.rs:162:65 (arc_swap-a1768ea5572bf654+0xdf8aa)
    #8 _$LT$core..panic..unwind_safe..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::haee83a11e98b1ebc /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:271:9 (arc_swap-a1768ea5572bf654+0xf3b20)
    #9 std::panicking::try::do_call::h0a816b8087cdf13f /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:406:40 (arc_swap-a1768ea5572bf654+0xf5a0a)
    #10 __rust_try 46q4l7863lajlfyb (arc_swap-a1768ea5572bf654+0xf6fe8)
    #11 std::panicking::try::h9aa7612f6f5036b4 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:370:19 (arc_swap-a1768ea5572bf654+0xf5102)
    #12 std::panic::catch_unwind::hb1629b867c5b7d3b /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:133:14 (arc_swap-a1768ea5572bf654+0x10a9f0)
    #13 crossbeam_utils::thread::scope::hee133044b35ad8fd /home/nobodyxu/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.1/src/thread.rs:162:18 (arc_swap-a1768ea5572bf654+0xde55b)
    #14 arc_swap::tests_default::rcu::he018d1d919ddec6e /home/nobodyxu/Dev/arc-swap/src/lib.rs:1147:17 (arc_swap-a1768ea5572bf654+0xd22a4)
    #15 arc_swap::tests_default::rcu::_$u7b$$u7b$closure$u7d$$u7d$::h1c58c438b8b61300 /home/nobodyxu/Dev/arc-swap/src/lib.rs:1143:13 (arc_swap-a1768ea5572bf654+0xca791)
    #16 core::ops::function::FnOnce::call_once::h7c7a226754085154 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 (arc_swap-a1768ea5572bf654+0xb94e7)
    #17 core::ops::function::FnOnce::call_once::hb81219a3a5574e0d /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 (arc_swap-a1768ea5572bf654+0x1a094e)
    #18 test::__rust_begin_short_backtrace::hc71431af1903e77b /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:585:5 (arc_swap-a1768ea5572bf654+0x1de285)
    #19 test::run_test::_$u7b$$u7b$closure$u7d$$u7d$::hafa7836b79e6a84c /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:576:30 (arc_swap-a1768ea5572bf654+0x1dd121)
    #20 core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h702f3abbcdb74f00 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 (arc_swap-a1768ea5572bf654+0x19f92e)
    #21 _$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..FnOnce$LT$Args$GT$$GT$::call_once::hf6de0726e1706af5 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1811:9 (arc_swap-a1768ea5572bf654+0x1c5494)
    #22 _$LT$core..panic..unwind_safe..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::h887b5a540163d6ca /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:271:9 (arc_swap-a1768ea5572bf654+0x184cb4)
    #23 std::panicking::try::do_call::ha3f9f4ebee654392 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:406:40 (arc_swap-a1768ea5572bf654+0x186cd2)
    #24 __rust_try test.200d92bc-cgu.13 (arc_swap-a1768ea5572bf654+0x18f1d8)
    #25 std::panicking::try::hbb5d8a48518ef1b9 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:370:19 (arc_swap-a1768ea5572bf654+0x186942)
    #26 std::panic::catch_unwind::h2c3ba6136512c7a0 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:133:14 (arc_swap-a1768ea5572bf654+0x185124)
    #27 test::run_test_in_process::h382f64c350b24b5d /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:608:18 (arc_swap-a1768ea5572bf654+0x1de602)
    #28 test::run_test::run_test_inner::_$u7b$$u7b$closure$u7d$$u7d$::he81ffb33c672e6dd /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:500:39 (arc_swap-a1768ea5572bf654+0x1dded8)
    #29 test::run_test::run_test_inner::_$u7b$$u7b$closure$u7d$$u7d$::hd865da0c3a692927 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:527:37 (arc_swap-a1768ea5572bf654+0x1de12a)
    #30 std::sys_common::backtrace::__rust_begin_short_backtrace::he0d056c803c7b37c /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:123:18 (arc_swap-a1768ea5572bf654+0x184ff1)
    #31 std::thread::Builder::spawn_unchecked::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h5f5177097fcfe840 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:477:17 (arc_swap-a1768ea5572bf654+0x186225)
    #32 _$LT$core..panic..unwind_safe..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::hf2387297fea4c3a7 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:271:9 (arc_swap-a1768ea5572bf654+0x184de5)
    #33 std::panicking::try::do_call::h3321a8597b07e432 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:406:40 (arc_swap-a1768ea5572bf654+0x186a3e)
    #34 __rust_try test.200d92bc-cgu.13 (arc_swap-a1768ea5572bf654+0x18f1d8)
    #35 std::panicking::try::h7468cf75cc472c84 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:370:19 (arc_swap-a1768ea5572bf654+0x1867f6)
    #36 std::panic::catch_unwind::h7e598a4e380a1bd3 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:133:14 (arc_swap-a1768ea5572bf654+0x185185)
    #37 std::thread::Builder::spawn_unchecked::_$u7b$$u7b$closure$u7d$$u7d$::h379f61b76aa5aaa7 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:476:30 (arc_swap-a1768ea5572bf654+0x185f61)
    #38 core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h517dc5422141019f /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 (arc_swap-a1768ea5572bf654+0x19f8d5)
    #39 _$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..FnOnce$LT$Args$GT$$GT$::call_once::h7c51f785c4bdd214 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1811:9 (arc_swap-a1768ea5572bf654+0x388074)
    #40 _$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..FnOnce$LT$Args$GT$$GT$::call_once::hbbe111351615a74a /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1811:9 (arc_swap-a1768ea5572bf654+0x38814e)
    #41 std::sys::unix::thread::Thread::new::thread_start::he6142c0fcd17dea0 /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/thread.rs:108:17 (arc_swap-a1768ea5572bf654+0x2d4ae1)

SUMMARY: ThreadSanitizer: data race /home/nobodyxu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/alloc.rs:42:9 in std::sys::unix::alloc::_$LT$impl$u20$core..alloc..global..GlobalAlloc$u20$for$u20$std..alloc..System$GT$::dealloc::h2a676766609ecfae
==================
test tests::lease_overflow ... ok
test tests_default::load_null ... ok
test tests_default::load_option ... ok
test tests_default::nulls ... ok
test tests_default::rcu_panic ... ok
test tests_default::guard_drop_in_another_thread ... ok
test tests_default::cas_ref_cnt ... ok
test tests_default::recursive ... ok
test tests_default::rcu ... ok
test tests_default::publish ... ok
test tests_default::guard_drop_in_thread ... ok
test tests_default::swap_load ... ok
test tests_default::multi_writers ... ok

test result: ok. 32 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.54s

ThreadSanitizer: reported 1 warnings
error: test failed, to rerun pass '--lib'

I am using cargo-1.58.0-nightly on Linux:

cargo 1.58.0-nightly (40dc28175 2021-12-06)
release: 1.58.0
commit-hash: 40dc281755137ee804bc9b3b08e782773b726e44
commit-date: 2021-12-06
host: x86_64-unknown-linux-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1l)
os: Linux 2.7 [64-bit]

clang --version

clang version 13.0.0
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/13/bin

gcc --version:

gcc (Gentoo 11.2.1_p20211127 p0) 11.2.1 20211127
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I opened PR #72 to add thread sanitizer, which also reports data race when dropping Arc.

Hello

Are you sure this one is not a false positive of the thread sanitizer? Last time I've spent several hours examining it, I've reached the conclusion the thread sanitizer somehow doesn't understand this synchronization pattern and doesn't see it, but I had a proof that it is correct according to the spec (it's even written in the code).

I know there was some time since then, so maybe it's behaving better and this one may be legitimate, but I don't really have much time to spend 10 hours looking for something to finally prove that it is imperfection of the sanitizer.

Would you be able to pinpoint it somewhat better? Having a smaller reproducer, or following the proof/code path and looking at where it happens?

Same goes for the linked pull request… it would be nice for it to be green and to keep checking things, but as it is red now, it probably shouldn't go in yet before the issue is resolved.

I am not so sure that this is not a false positive, given that it also reports data race in parking_lock::RwLock and owner of parking_lot cannot reproduce that.

I am not so familiar with arc-swap, so I would try to pinpoint it, however it might quite challenging.

From a quick glance at the backtrace. This seems to happen during dropping of an Arc inside an allocator. Now, that happening in allocator is already somewhat suspicious. Nevertheless, I could imagine the allocator doing these things if I try to deallocate memory that wasn't „brought into“ the current thread. As in, one thread allocates some memory, passes the pointer to other thread without synchronization and the other thread deallocates.

I believe this isn't the case in the test, for two reasons:

  • The Arc inside an ArcSwap is represented as a raw pointer. Every read/load of that pointer (that's not double-checking the value of the pointer, but actually getting the Arc out of it) is at least an Acquire, every write is at least a Release. That in combination assures that every instance of Arc that passes through is properly „sent“ between the threads. Now, I haven't done a full read of the crate to verify this is true, but when I was working on it back then, I did pay attention to this thing. You're welcome to trace this through and verify, more eyes are always better.
  • There's a barrier in between allocating all the arcs and dropping them in the test. That one ensures propagation of everything to all threads participating on that barrier. So even if ArcSwap was not doing its job properly, the test itself should ensure that.
  • Arc itself is responsible for decreasing its own reference counts correctly as long as each thread got the pointed-to data in a correct way.

All in all, this seems to me to be either a false positive of the thread sanitizer, a bug in the allocator or some platform specific optimization in the allocator that is technically not correct according to the language spec but known to work on the given platform & compiler (platforms are allowed to provide stronger guarantees than the language and I wouldn't be surprised if things like allocators took advantage of that).

I'll keep this open for now, so you or others can go and verify my claims. Also, trying the test with a different allocator could show us something (but I'm not sure what).

Thanks for explanation and taking your time to investigate on this issue!

If this is a bug in the allocator that does not work on the given platform, then maybe I can try to run the thread sanitizer on other platforms such as arm64 and tests its behavior.

I can also try another allocator to see if it makes a difference.

MacOS is able to run the thread sanitizer without any problem.

This seems like to be a platform specific problem.

Ok, then I'll close this one.