ThreadSanitizer: data race lib/isc/log.c - multiple issues
Found in logfileconfig
test:
WARNING: ThreadSanitizer: data race (pid=1260)
Read of size 8 at 0x7b9400000068 by thread T21 (mutexes: write M944203102091890528, write M246707628766581536):
#0 isc_log_wouldlog /home/ondrej/Projects/bind9/lib/isc/log.c:1479 (libisc.so.1504+0x31379)
#1 socket_log /home/ondrej/Projects/bind9/lib/isc/unix/socket.c:640 (libisc.so.1504+0x6c3b3)
#2 internal_accept /home/ondrej/Projects/bind9/lib/isc/unix/socket.c:2784 (libisc.so.1504+0x70a08)
#3 process_fd /home/ondrej/Projects/bind9/lib/isc/unix/socket.c:3160 (libisc.so.1504+0x70a08)
#4 process_fds /home/ondrej/Projects/bind9/lib/isc/unix/socket.c:3257 (libisc.so.1504+0x70a08)
#5 netthread /home/ondrej/Projects/bind9/lib/isc/unix/socket.c:3503 (libisc.so.1504+0x70a08)
#6 <null> <null> (libtsan.so.0+0x29b3d)
Previous write of size 8 at 0x7b9400000068 by thread T9 (mutexes: write M29):
#0 isc_logconfig_use /home/ondrej/Projects/bind9/lib/isc/log.c:426 (libisc.so.1504+0x2f4d7)
#1 load_configuration server.c:9108 (named+0x5945a)
#2 run_server server.c:9654 (named+0x59a47)
#3 dispatch /home/ondrej/Projects/bind9/lib/isc/task.c:1134 (libisc.so.1504+0x56fa6)
#4 run /home/ondrej/Projects/bind9/lib/isc/task.c:1319 (libisc.so.1504+0x56fa6)
#5 <null> <null> (libtsan.so.0+0x29b3d)
Location is heap block of size 8321 at 0x7b9400000000 allocated by main thread:
#0 malloc <null> (libtsan.so.0+0x2b1a3)
#1 default_memalloc /home/ondrej/Projects/bind9/lib/isc/mem.c:685 (libisc.so.1504+0x33fee)
#2 mem_get /home/ondrej/Projects/bind9/lib/isc/mem.c:598 (libisc.so.1504+0x34c7e)
#3 mem_allocateunlocked /home/ondrej/Projects/bind9/lib/isc/mem.c:1222 (libisc.so.1504+0x34c7e)
#4 isc___mem_allocate /home/ondrej/Projects/bind9/lib/isc/mem.c:1242 (libisc.so.1504+0x34c7e)
#5 isc__mem_allocate /home/ondrej/Projects/bind9/lib/isc/mem.c:2387 (libisc.so.1504+0x3be64)
#6 isc___mem_get /home/ondrej/Projects/bind9/lib/isc/mem.c:1007 (libisc.so.1504+0x3c6ca)
#7 isc__mem_get /home/ondrej/Projects/bind9/lib/isc/mem.c:2365 (libisc.so.1504+0x3aef1)
#8 isc_log_create /home/ondrej/Projects/bind9/lib/isc/log.c:262 (libisc.so.1504+0x30731)
#9 named_log_init /home/ondrej/Projects/bind9/bin/named/log.c:61 (named+0x26f38)
#10 setup main.c:1043 (named+0x1a6db)
#11 main main.c:1515 (named+0x1a6db)
Mutex M944203102091890528 is already destroyed.
Mutex M246707628766581536 is already destroyed.
Mutex M29 (0x7b9400000040) created at:
#0 pthread_mutex_init <null> (libtsan.so.0+0x2c5ad)
#1 isc__mutex_init /home/ondrej/Projects/bind9/lib/isc/pthreads/mutex.c:284 (libisc.so.1504+0x7bc06)
#2 isc_log_create /home/ondrej/Projects/bind9/lib/isc/log.c:274 (libisc.so.1504+0x3081b)
#3 named_log_init /home/ondrej/Projects/bind9/bin/named/log.c:61 (named+0x26f38)
#4 setup main.c:1043 (named+0x1a6db)
#5 main main.c:1515 (named+0x1a6db)
Thread T21 'isc-socket-3' (tid=1350, running) created by main thread at:
#0 pthread_create <null> (libtsan.so.0+0x2be1b)
#1 isc_thread_create /home/ondrej/Projects/bind9/lib/isc/pthreads/thread.c:75 (libisc.so.1504+0x7bcc4)
#2 isc_socketmgr_create2 /home/ondrej/Projects/bind9/lib/isc/unix/socket.c:3817 (libisc.so.1504+0x74ce2)
#3 create_managers main.c:919 (named+0x1af64)
#4 setup main.c:1235 (named+0x1af64)
#5 main main.c:1515 (named+0x1af64)
Thread T9 'isc-worker0000' (tid=1327, running) created by main thread at:
#0 pthread_create <null> (libtsan.so.0+0x2be1b)
#1 isc_thread_create /home/ondrej/Projects/bind9/lib/isc/pthreads/thread.c:75 (libisc.so.1504+0x7bcc4)
#2 isc_taskmgr_create /home/ondrej/Projects/bind9/lib/isc/task.c:1410 (libisc.so.1504+0x59d63)
#3 create_managers main.c:902 (named+0x1aeec)
#4 setup main.c:1235 (named+0x1aeec)
#5 main main.c:1515 (named+0x1aeec)
SUMMARY: ThreadSanitizer: data race /home/ondrej/Projects/bind9/lib/isc/log.c:1479 in isc_log_wouldlog
WARNING: ThreadSanitizer: data race (pid=1260)
Read of size 4 at 0x7b18000059e0 by thread T21 (mutexes: write M944203102091890528, write M246707628766581536):
#0 isc_log_wouldlog /home/ondrej/Projects/bind9/lib/isc/log.c:1482 (libisc.so.1504+0x3138c)
#1 socket_log /home/ondrej/Projects/bind9/lib/isc/unix/socket.c:640 (libisc.so.1504+0x6c3b3)
#2 internal_accept /home/ondrej/Projects/bind9/lib/isc/unix/socket.c:2784 (libisc.so.1504+0x70a08)
#3 process_fd /home/ondrej/Projects/bind9/lib/isc/unix/socket.c:3160 (libisc.so.1504+0x70a08)
#4 process_fds /home/ondrej/Projects/bind9/lib/isc/unix/socket.c:3257 (libisc.so.1504+0x70a08)
#5 netthread /home/ondrej/Projects/bind9/lib/isc/unix/socket.c:3503 (libisc.so.1504+0x70a08)
#6 <null> <null> (libtsan.so.0+0x29b3d)
Previous write of size 4 at 0x7b18000059e0 by thread T9:
#0 assignchannel /home/ondrej/Projects/bind9/lib/isc/log.c:1000 (libisc.so.1504+0x2e13a)
#1 isc_log_usechannel /home/ondrej/Projects/bind9/lib/isc/log.c:786 (libisc.so.1504+0x30ab2)
#2 category_fromconf /home/ondrej/Projects/bind9/bin/named/logconf.c:75 (named+0x27872)
#3 named_logconfig /home/ondrej/Projects/bind9/bin/named/logconf.c:329 (named+0x27872)
#4 load_configuration server.c:9097 (named+0x5941b)
#5 run_server server.c:9654 (named+0x59a47)
#6 dispatch /home/ondrej/Projects/bind9/lib/isc/task.c:1134 (libisc.so.1504+0x56fa6)
#7 run /home/ondrej/Projects/bind9/lib/isc/task.c:1319 (libisc.so.1504+0x56fa6)
#8 <null> <null> (libtsan.so.0+0x29b3d)
Location is heap block of size 89 at 0x7b18000059a0 allocated by thread T9:
#0 malloc <null> (libtsan.so.0+0x2b1a3)
#1 default_memalloc /home/ondrej/Projects/bind9/lib/isc/mem.c:685 (libisc.so.1504+0x33fee)
#2 mem_get /home/ondrej/Projects/bind9/lib/isc/mem.c:598 (libisc.so.1504+0x34c7e)
#3 mem_allocateunlocked /home/ondrej/Projects/bind9/lib/isc/mem.c:1222 (libisc.so.1504+0x34c7e)
#4 isc___mem_allocate /home/ondrej/Projects/bind9/lib/isc/mem.c:1242 (libisc.so.1504+0x34c7e)
#5 isc__mem_allocate /home/ondrej/Projects/bind9/lib/isc/mem.c:2387 (libisc.so.1504+0x3be64)
#6 isc___mem_get /home/ondrej/Projects/bind9/lib/isc/mem.c:1007 (libisc.so.1504+0x3c6ca)
#7 isc__mem_get /home/ondrej/Projects/bind9/lib/isc/mem.c:2365 (libisc.so.1504+0x3aef1)
#8 isc_logconfig_create /home/ondrej/Projects/bind9/lib/isc/log.c:322 (libisc.so.1504+0x3035f)
#9 isc_logconfig_create /home/ondrej/Projects/bind9/lib/isc/log.c:313 (libisc.so.1504+0x3035f)
#10 load_configuration server.c:9091 (named+0x593a2)
#11 run_server server.c:9654 (named+0x59a47)
#12 dispatch /home/ondrej/Projects/bind9/lib/isc/task.c:1134 (libisc.so.1504+0x56fa6)
#13 run /home/ondrej/Projects/bind9/lib/isc/task.c:1319 (libisc.so.1504+0x56fa6)
#14 <null> <null> (libtsan.so.0+0x29b3d)
Mutex M944203102091890528 is already destroyed.
Mutex M246707628766581536 is already destroyed.
Thread T21 'isc-socket-3' (tid=1350, running) created by main thread at:
#0 pthread_create <null> (libtsan.so.0+0x2be1b)
#1 isc_thread_create /home/ondrej/Projects/bind9/lib/isc/pthreads/thread.c:75 (libisc.so.1504+0x7bcc4)
#2 isc_socketmgr_create2 /home/ondrej/Projects/bind9/lib/isc/unix/socket.c:3817 (libisc.so.1504+0x74ce2)
#3 create_managers main.c:919 (named+0x1af64)
#4 setup main.c:1235 (named+0x1af64)
#5 main main.c:1515 (named+0x1af64)
Thread T9 'isc-worker0000' (tid=1327, running) created by main thread at:
#0 pthread_create <null> (libtsan.so.0+0x2be1b)
#1 isc_thread_create /home/ondrej/Projects/bind9/lib/isc/pthreads/thread.c:75 (libisc.so.1504+0x7bcc4)
#2 isc_taskmgr_create /home/ondrej/Projects/bind9/lib/isc/task.c:1410 (libisc.so.1504+0x59d63)
#3 create_managers main.c:902 (named+0x1aeec)
#4 setup main.c:1235 (named+0x1aeec)
#5 main main.c:1515 (named+0x1aeec)
SUMMARY: ThreadSanitizer: data race /home/ondrej/Projects/bind9/lib/isc/log.c:1482 in isc_log_wouldlog
WARNING: ThreadSanitizer: data race (pid=1260)
Read of size 1 at 0x7b18000059f0 by thread T21 (mutexes: write M944203102091890528, write M246707628766581536):
#0 isc_log_wouldlog /home/ondrej/Projects/bind9/lib/isc/log.c:1483 (libisc.so.1504+0x313b9)
#1 socket_log /home/ondrej/Projects/bind9/lib/isc/unix/socket.c:640 (libisc.so.1504+0x6c3b3)
#2 internal_accept /home/ondrej/Projects/bind9/lib/isc/unix/socket.c:2784 (libisc.so.1504+0x70a08)
#3 process_fd /home/ondrej/Projects/bind9/lib/isc/unix/socket.c:3160 (libisc.so.1504+0x70a08)
#4 process_fds /home/ondrej/Projects/bind9/lib/isc/unix/socket.c:3257 (libisc.so.1504+0x70a08)
#5 netthread /home/ondrej/Projects/bind9/lib/isc/unix/socket.c:3503 (libisc.so.1504+0x70a08)
#6 <null> <null> (libtsan.so.0+0x29b3d)
Previous write of size 8 at 0x7b18000059f0 by thread T9 (mutexes: write M15):
#0 malloc <null> (libtsan.so.0+0x2b1a3)
#1 default_memalloc /home/ondrej/Projects/bind9/lib/isc/mem.c:685 (libisc.so.1504+0x33fee)
#2 mem_get /home/ondrej/Projects/bind9/lib/isc/mem.c:598 (libisc.so.1504+0x34c7e)
#3 mem_allocateunlocked /home/ondrej/Projects/bind9/lib/isc/mem.c:1222 (libisc.so.1504+0x34c7e)
#4 isc___mem_allocate /home/ondrej/Projects/bind9/lib/isc/mem.c:1242 (libisc.so.1504+0x34c7e)
#5 isc__mem_allocate /home/ondrej/Projects/bind9/lib/isc/mem.c:2387 (libisc.so.1504+0x3be64)
#6 isc___mem_get /home/ondrej/Projects/bind9/lib/isc/mem.c:1007 (libisc.so.1504+0x3c6ca)
#7 isc__mem_get /home/ondrej/Projects/bind9/lib/isc/mem.c:2365 (libisc.so.1504+0x3aef1)
#8 isc_logconfig_create /home/ondrej/Projects/bind9/lib/isc/log.c:322 (libisc.so.1504+0x3035f)
#9 isc_logconfig_create /home/ondrej/Projects/bind9/lib/isc/log.c:313 (libisc.so.1504+0x3035f)
#10 load_configuration server.c:9091 (named+0x593a2)
#11 run_server server.c:9654 (named+0x59a47)
#12 dispatch /home/ondrej/Projects/bind9/lib/isc/task.c:1134 (libisc.so.1504+0x56fa6)
#13 run /home/ondrej/Projects/bind9/lib/isc/task.c:1319 (libisc.so.1504+0x56fa6)
#14 <null> <null> (libtsan.so.0+0x29b3d)
Location is heap block of size 89 at 0x7b18000059a0 allocated by thread T9:
#0 malloc <null> (libtsan.so.0+0x2b1a3)
#1 default_memalloc /home/ondrej/Projects/bind9/lib/isc/mem.c:685 (libisc.so.1504+0x33fee)
#2 mem_get /home/ondrej/Projects/bind9/lib/isc/mem.c:598 (libisc.so.1504+0x34c7e)
#3 mem_allocateunlocked /home/ondrej/Projects/bind9/lib/isc/mem.c:1222 (libisc.so.1504+0x34c7e)
#4 isc___mem_allocate /home/ondrej/Projects/bind9/lib/isc/mem.c:1242 (libisc.so.1504+0x34c7e)
#5 isc__mem_allocate /home/ondrej/Projects/bind9/lib/isc/mem.c:2387 (libisc.so.1504+0x3be64)
#6 isc___mem_get /home/ondrej/Projects/bind9/lib/isc/mem.c:1007 (libisc.so.1504+0x3c6ca)
#7 isc__mem_get /home/ondrej/Projects/bind9/lib/isc/mem.c:2365 (libisc.so.1504+0x3aef1)
#8 isc_logconfig_create /home/ondrej/Projects/bind9/lib/isc/log.c:322 (libisc.so.1504+0x3035f)
#9 isc_logconfig_create /home/ondrej/Projects/bind9/lib/isc/log.c:313 (libisc.so.1504+0x3035f)
#10 load_configuration server.c:9091 (named+0x593a2)
#11 run_server server.c:9654 (named+0x59a47)
#12 dispatch /home/ondrej/Projects/bind9/lib/isc/task.c:1134 (libisc.so.1504+0x56fa6)
#13 run /home/ondrej/Projects/bind9/lib/isc/task.c:1319 (libisc.so.1504+0x56fa6)
#14 <null> <null> (libtsan.so.0+0x29b3d)
Mutex M944203102091890528 is already destroyed.
Mutex M246707628766581536 is already destroyed.
Mutex M15 (0x7b4800000198) created at:
#0 pthread_mutex_init <null> (libtsan.so.0+0x2c5ad)
#1 isc__mutex_init /home/ondrej/Projects/bind9/lib/isc/pthreads/mutex.c:284 (libisc.so.1504+0x7bc06)
#2 mem_create /home/ondrej/Projects/bind9/lib/isc/mem.c:737 (libisc.so.1504+0x3a749)
#3 isc_mem_create /home/ondrej/Projects/bind9/lib/isc/mem.c:2358 (libisc.so.1504+0x3a749)
#4 main main.c:1512 (named+0x1a64b)
Thread T21 'isc-socket-3' (tid=1350, running) created by main thread at:
#0 pthread_create <null> (libtsan.so.0+0x2be1b)
#1 isc_thread_create /home/ondrej/Projects/bind9/lib/isc/pthreads/thread.c:75 (libisc.so.1504+0x7bcc4)
#2 isc_socketmgr_create2 /home/ondrej/Projects/bind9/lib/isc/unix/socket.c:3817 (libisc.so.1504+0x74ce2)
#3 create_managers main.c:919 (named+0x1af64)
#4 setup main.c:1235 (named+0x1af64)
#5 main main.c:1515 (named+0x1af64)
Thread T9 'isc-worker0000' (tid=1327, running) created by main thread at:
#0 pthread_create <null> (libtsan.so.0+0x2be1b)
#1 isc_thread_create /home/ondrej/Projects/bind9/lib/isc/pthreads/thread.c:75 (libisc.so.1504+0x7bcc4)
#2 isc_taskmgr_create /home/ondrej/Projects/bind9/lib/isc/task.c:1410 (libisc.so.1504+0x59d63)
#3 create_managers main.c:902 (named+0x1aeec)
#4 setup main.c:1235 (named+0x1aeec)
#5 main main.c:1515 (named+0x1aeec)
SUMMARY: ThreadSanitizer: data race /home/ondrej/Projects/bind9/lib/isc/log.c:1483 in isc_log_wouldlog
Edited by Ondřej Surý