https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79455
kelvin at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kelvin at gcc dot gnu.org --- Comment #1 from kelvin at gcc dot gnu.org --- As of today (svn revision 245252), I'm seeing intermittent success. This turned up during routine regression testing of a proposed patch. Consistently, the bootstrapped gcc version before my patch was applied succeeds. Here is an excerpt from that gcc.log file: ================== WARNING: ThreadSanitizer: data race (pid=104133) Atomic read of size 1 at 0x0000100200d8 by thread T2: #0 pthread_mutex_lock /home/kelvin/gcc-root/gcc-trunk4ltc92025.b4patch/libs\ anitizer/sanitizer_common/sanitizer_common_interceptors.inc:3607 (libtsan.so.0+\ 0x0000000446a4) #1 Thread2 /home/kelvin/gcc-root/gcc-trunk4ltc92025.b4patch/gcc/testsuite/c\ -c++-common/tsan/race_on_mutex.c:22 (race_on_mutex.exe+0x000010000e84) Previous write of size 1 at 0x0000100200d8 by thread T1: #0 pthread_mutex_init /home/kelvin/gcc-root/gcc-trunk4ltc92025.b4patch/libs\ anitizer/tsan/tsan_interceptors.cc:1117 (libtsan.so.0+0x00000002d1f8) #1 Thread1 /home/kelvin/gcc-root/gcc-trunk4ltc92025.b4patch/gcc/testsuite/c\ -c++-common/tsan/race_on_mutex.c:12 (race_on_mutex.exe+0x000010000d54) Location is global 'Mtx' of size 40 at 0x0000100200d8 (race_on_mutex.exe+0x00\ 00100200d8) Thread T2 (tid=104335, running) created by main thread at: #0 pthread_create /home/kelvin/gcc-root/gcc-trunk4ltc92025.b4patch/libsanit\ izer/tsan/tsan_interceptors.cc:900 (libtsan.so.0+0x00000002c53c) #1 main /home/kelvin/gcc-root/gcc-trunk4ltc92025.b4patch/gcc/testsuite/c-c+\ +-common/tsan/race_on_mutex.c:32 (race_on_mutex.exe+0x000010000f70) Thread T1 (tid=104334, finished) created by main thread at: #0 pthread_create /home/kelvin/gcc-root/gcc-trunk4ltc92025.b4patch/libsanit\ izer/tsan/tsan_interceptors.cc:900 (libtsan.so.0+0x00000002c53c) #1 main /home/kelvin/gcc-root/gcc-trunk4ltc92025.b4patch/gcc/testsuite/c-c+\ +-common/tsan/race_on_mutex.c:31 (race_on_mutex.exe+0x000010000f50) SUMMARY: ThreadSanitizer: data race /home/kelvin/gcc-root/gcc-trunk4ltc92025.b4\ patch/gcc/testsuite/c-c++-common/tsan/race_on_mutex.c:22 in Thread2 ================== ThreadSanitizer: reported 1 warnings PASS: c-c++-common/tsan/race_on_mutex.c -O0 execution test PASS: c-c++-common/tsan/race_on_mutex.c -O0 output pattern test, WARNING: Th\ readSanitizer: data race.*( |^M |^M) Atomic read of size 1 at .* by thread T2:( |^M |^M) #0 pthread_mutex_lock.* #1 Thread2.* .*(race_on_mutex.c:22|\?{2}:0) \ (.*) Previous write of size 1 at .* by thread T1:( |^M |^M) #0 pthread_mutex_init .* (.)* #1 Thread1.* .*(race_on_mutex.c:12|\?{\ 2}:0) .* With the gcc.log output for the version of gcc that has my patch, this test is consistently failing. The relevant part of the trace output on the version that fails is quoted below. Note that the "previous write was of size 8" instead of size 1, which is what the dg-output directive is looking for. ================== WARNING: ThreadSanitizer: data race (pid=36311) Atomic read of size 1 at 0x0000100200d8 by thread T2: #0 pthread_mutex_lock /home/kelvin/gcc-root/gcc-trunk4ltc92025/libsanitizer\ /sanitizer_common/sanitizer_common_interceptors.inc:3607 (libtsan.so.0+0x000000\ 044704) #1 Thread2 /home/kelvin/gcc-root/gcc-trunk4ltc92025/gcc/testsuite/c-c++-com\ mon/tsan/race_on_mutex.c:22 (race_on_mutex.exe+0x000010000f24) Previous write of size 8 at 0x0000100200d8 by thread T1: #0 memset /home/kelvin/gcc-root/gcc-trunk4ltc92025/libsanitizer/sanitizer_c\ ommon/sanitizer_common_interceptors.inc:558 (libtsan.so.0+0x000000036154) #1 pthread_mutex_init <null> (libpthread.so.0+0x00000000b61c) #2 Thread1 /home/kelvin/gcc-root/gcc-trunk4ltc92025/gcc/testsuite/c-c++-com\ mon/tsan/race_on_mutex.c:12 (race_on_mutex.exe+0x000010000df4) Location is global 'Mtx' of size 40 at 0x0000100200d8 (race_on_mutex.exe+0x00\ 00100200d8) Thread T2 (tid=36382, running) created by main thread at: #0 pthread_create /home/kelvin/gcc-root/gcc-trunk4ltc92025/libsanitizer/tsa\ n/tsan_interceptors.cc:900 (libtsan.so.0+0x00000002c59c) #1 main /home/kelvin/gcc-root/gcc-trunk4ltc92025/gcc/testsuite/c-c++-common\ /tsan/race_on_mutex.c:32 (race_on_mutex.exe+0x000010001010) Thread T1 (tid=36378, finished) created by main thread at: #0 pthread_create /home/kelvin/gcc-root/gcc-trunk4ltc92025/libsanitizer/tsa\ n/tsan_interceptors.cc:900 (libtsan.so.0+0x00000002c59c) #1 main /home/kelvin/gcc-root/gcc-trunk4ltc92025/gcc/testsuite/c-c++-common\ /tsan/race_on_mutex.c:31 (race_on_mutex.exe+0x000010000ff0) SUMMARY: ThreadSanitizer: data race /home/kelvin/gcc-root/gcc-trunk4ltc92025/gc\ c/testsuite/c-c++-common/tsan/race_on_mutex.c:22 in Thread2 ================== ThreadSanitizer: reported 1 warnings PASS: c-c++-common/tsan/race_on_mutex.c -O0 execution test FAIL: c-c++-common/tsan/race_on_mutex.c -O0 output pattern test, is ========\ ========== WARNING: ThreadSanitizer: data race (pid=36311) Atomic read of size 1 at 0x0000100200d8 by thread T2: #0 pthread_mutex_lock gcc-trunk4ltc92025/libsanitizer/sanitizer_common/sani\ tizer_common_interceptors.inc:3607 (libtsan.so.0+0x000000044704) #1 Thread2 c-c++-common/tsan/race_on_mutex.c:22 (race_on_mutex.exe+0x000010\ 000f24) Previous write of size 8 at 0x0000100200d8 by thread T1: #0 memset gcc-trunk4ltc92025/libsanitizer/sanitizer_common/sanitizer_common\ _interceptors.inc:558 (libtsan.so.0+0x000000036154) #1 pthread_mutex_init <null> (libpthread.so.0+0x00000000b61c) #2 Thread1 c-c++-common/tsan/race_on_mutex.c:12 (race_on_mutex.exe+0x000010\ 000df4) Location is global 'Mtx' of size 40 at 0x0000100200d8 (race_on_mutex.exe+0x00\ 00100200d8) Thread T2 (tid=36382, running) created by main thread at: #0 pthread_create gcc-trunk4ltc92025/libsanitizer/tsan/tsan_interceptors.cc\ :900 (libtsan.so.0+0x00000002c59c) #1 main c-c++-common/tsan/race_on_mutex.c:32 (race_on_mutex.exe+0x000010001\ 010) Thread T1 (tid=36378, finished) created by main thread at: #0 pthread_create gcc-trunk4ltc92025/libsanitizer/tsan/tsan_interceptors.cc\ :900 (libtsan.so.0+0x00000002c59c) #1 main c-c++-common/tsan/race_on_mutex.c:31 (race_on_mutex.exe+0x000010000\ ff0) SUMMARY: ThreadSanitizer: data race c-c++-common/tsan/race_on_mutex.c:22 in Thr\ ead2 ================== ThreadSanitizer: reported 1 warnings , should match WARNING: ThreadSanitizer: data race.*( |^M |^M) Atomic read of size 1 at .* by thread T2:( |^M |^M) #0 pthread_mutex_lock.* #1 Thread2.* .*(race_on_mutex.c:22|\?{2}:0) \ (.*) Previous write of size 1 at .* by thread T1:( |^M |^M) #0 pthread_mutex_init .* (.)* #1 Thread1.* .*(race_on_mutex.c:12|\?{\ 2}:0) .* Apparently, the "ThreadSanitizer: data race" warning is only copied to the testsuite summary file if the test fails. I don't understand this test well enough to know why the write of size 1 is converted into a write of size 8, though I'm guessing it might have something to do with memory alignment and/or cache coherence. Could it result from differences between the fast paths and short paths through the library implementation of the pthread_mutex_lock and unlock services?