$ cat tsan.c #include int Global; void *Thread1(void *x) { Global = 42; return x; } int main() { pthread_t t; pthread_create(&t, NULL, Thread1, NULL); Global = 43; pthread_join(t, NULL); return Global; } $ ./bin/clang -O0 -g -fsanitize=thread tsan.c LINUX $ ./a.out ================== WARNING: ThreadSanitizer: data race (pid=5784) Write of size 4 at 0x0000014aee78 by main thread: #0 main /home/kamil/tsan.c:10:10 (a.out+0x0000004a428e) Previous write of size 4 at 0x0000014aee78 by thread T1: #0 Thread1 /home/kamil/tsan.c:4:10 (a.out+0x0000004a4247) Location is global 'Global' of size 4 at 0x0000014aee78 (a.out+0x0000014aee78) Thread T1 (tid=5786, finished) created by main thread at: #0 pthread_create (a.out+0x000000424bd6) #1 main /home/kamil/tsan.c:9:3 (a.out+0x0000004a4284) SUMMARY: ThreadSanitizer: data race /home/kamil/tsan.c:10:10 in main ================== ThreadSanitizer: reported 1 warnings NETBSD $ uname -a NetBSD chieftec 8.99.4 NetBSD 8.99.4 (GENERIC) #0: Sat Oct 14 16:12:26 CEST 2017 root@chieftec:/public/netbsd-root/sys/arch/amd64/compile/GENERIC amd64 $ gdb ./a.out GNU gdb (GDB) 7.12 Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64--netbsd". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./a.out...done. (gdb) r Starting program: /public/llvm-build/a.out [New LWP 2] ================== WARNING: ThreadSanitizer: data race (pid=1621) Write of size 4 at 0x000001475d70 by thread T1: #0 Thread1 /public/llvm-build/tsan.c:4:10 (a.out+0x46bf71) Previous write of size 4 at 0x000001475d70 by main thread: #0 main /public/llvm-build/tsan.c:10:10 (a.out+0x46bfe6) Location is global 'Global' of size 4 at 0x000001475d70 (a.out+0x000001475d70) Thread T1 (tid=2, running) created by main thread at: #0 pthread_create /public/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:930:3 (a.out+0x412120) #1 main /public/llvm-build/tsan.c:9:3 (a.out+0x46bfd1) SUMMARY: ThreadSanitizer: data race /public/llvm-build/tsan.c:4:10 in Thread1 ================== Thread 2 received signal SIGSEGV, Segmentation fault.