Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ make
- clang++ main.cpp -pthread -fsanitize=thread -O0 -g -ggdb3 -fPIE -pie -fPIC -std=c++11
- $ ./a.out
- ==================
- WARNING: ThreadSanitizer: data race (pid=11469)
- Write of size 1 at 0x7d040000f7f0 by thread T2:
- #0 operator delete(void*) ??:0 (exe+0x0000000425bb)
- #1 ReferenceCounted::release() /home/A.Romanek/tmp/tsan/main.cpp:16 (exe+0x0000000a08d2)
- #2 Thread2(void*) /home/A.Romanek/tmp/tsan/main.cpp:30 (exe+0x0000000a0663)
- Previous atomic write of size 4 at 0x7d040000f7f0 by thread T1:
- #0 __tsan_atomic32_fetch_sub ??:0 (exe+0x00000008528a)
- #1 std::__atomic_base<int>::fetch_sub(int, std::memory_order) /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/atomic_base.h:624 (exe+0x0000000a0e1f)
- #2 ReferenceCounted::release() /home/A.Romanek/tmp/tsan/main.cpp:13 (exe+0x0000000a08a1)
- #3 Thread1(void*) /home/A.Romanek/tmp/tsan/main.cpp:25 (exe+0x0000000a0603)
- Location is heap block of size 4 at 0x7d040000f7f0 allocated by main thread:
- #0 operator new(unsigned long) ??:0 (exe+0x000000041f49)
- #1 main /home/A.Romanek/tmp/tsan/main.cpp:35 (exe+0x0000000a069f)
- Thread T2 (tid=11472, running) created by main thread at:
- #0 pthread_create ??:0 (exe+0x000000045bfb)
- #1 main /home/A.Romanek/tmp/tsan/main.cpp:41 (exe+0x0000000a077e)
- Thread T1 (tid=11471, finished) created by main thread at:
- #0 pthread_create ??:0 (exe+0x000000045bfb)
- #1 main /home/A.Romanek/tmp/tsan/main.cpp:40 (exe+0x0000000a0742)
- SUMMARY: ThreadSanitizer: data race ??:0 operator delete(void*)
- ==================
- ThreadSanitizer: reported 1 warnings
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement