Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There is some a global variable read_time which is updated by all threads without proper synchronization. WARNING: ThreadSanitizer: data race (pid=15896) Read of size 4 at 0x00000066d53c by thread T7: #0 t_PairAlign(void*) /scratch/cluster/buczek/bsmap/bsmap.git/main.cpp:118 (bsmap+0x00000042c4f2) Previous write of size 4 at 0x00000066d53c by thread T6: [failed to restore the stack] Location is global 'read_time' of size 4 at 0x00000066d53c (bsmap+0x00000066d53c) Thread T7 (tid=15960, running) created by main thread at: #0 pthread_create /scratch/local/bee-root/gcc/gcc-5.3.0-0/source/libsanitizer/tsan/tsan_interceptors.cc:895 (libtsan.so.0+0x000000026c44) #1 Do_PairAlign() /scratch/cluster/buczek/bsmap/bsmap.git/main.cpp:128 (bsmap+0x00000042c613) #2 RunProcess() /scratch/cluster/buczek/bsmap/bsmap.git/main.cpp:499 (bsmap+0x0000004306b0) #3 main /scratch/cluster/buczek/bsmap/bsmap.git/main.cpp:611 (bsmap+0x0000004320ae) Thread T6 (tid=15959, finished) created by main thread at: #0 pthread_create /scratch/local/bee-root/gcc/gcc-5.3.0-0/source/libsanitizer/tsan/tsan_interceptors.cc:895 (libtsan.so.0+0x000000026c44) #1 Do_PairAlign() /scratch/cluster/buczek/bsmap/bsmap.git/main.cpp:128 (bsmap+0x00000042c613) #2 RunProcess() /scratch/cluster/buczek/bsmap/bsmap.git/main.cpp:499 (bsmap+0x0000004306b0) #3 main /scratch/cluster/buczek/bsmap/bsmap.git/main.cpp:611 (bsmap+0x0000004320ae) SUMMARY: ThreadSanitizer: data race /scratch/cluster/buczek/bsmap/bsmap.git/main.cpp:118 t_PairAlign(void*) ================== This is not a real issue, because the value is not currently used. But because we are holding the mutex_fout mutex at this point in code anyway, swap the order and work in the global first, then release the mutex. This puts read_time under the protection of mutex_fout.
- Loading branch information