ThreadSanitizer: data race dispatch.c:1501 in startrecv
Just launching named -g
compiled from c5b6f215 is enough to reproduce the issue:
WARNING: ThreadSanitizer: data race (pid=17397)
Read of size 4 at 0x7b540000ffc8 by thread T7 (mutexes: write M115258952081586624):
#0 startrecv dispatch.c:1501 (libdns.1503.dylib:x86_64+0x388c8)
#1 dns_dispatch_removeresponse dispatch.c:3371 (libdns.1503.dylib:x86_64+0x3a048)
#2 fctx_cancelquery resolver.c:1356 (libdns.1503.dylib:x86_64+0x13530c)
#3 process_sendevent resolver.c:1781 (libdns.1503.dylib:x86_64+0x14c03c)
#4 resquery_udpconnected resolver.c:1831 (libdns.1503.dylib:x86_64+0x143db2)
#5 run task.c:1134 (libisc.1503.dylib:x86_64+0x2c9e1)
Previous write of size 4 at 0x7b540000ffc8 by thread T5 (mutexes: write M96681603618684864, write M63748945444142984):
#0 free_buffer dispatch.c:901 (libdns.1503.dylib:x86_64+0x3962c)
#1 udp_recv dispatch.c:1106 (libdns.1503.dylib:x86_64+0x3d568)
#2 udp_exrecv dispatch.c:997 (libdns.1503.dylib:x86_64+0x3c26c)
#3 run task.c:1134 (libisc.1503.dylib:x86_64+0x2c9e1)
Location is heap block of size 609 at 0x7b540000ff00 allocated by thread T5:
#0 malloc <null>:7952976 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x4e65a)
#1 default_memalloc mem.c:685 (libisc.1503.dylib:x86_64+0x17ae1)
#2 run_server server.c:9588 (named:x86_64+0x10000db5a)
#3 run task.c:1134 (libisc.1503.dylib:x86_64+0x2c9e1)
Mutex M115258952081586624 is already destroyed.
Mutex M96681603618684864 is already destroyed.
Mutex M63748945444142984 is already destroyed.
Thread T7 (tid=4527470, running) created by main thread at:
#0 pthread_create <null>:7953024 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2a9cd)
#1 isc_thread_create thread.c:75 (libisc.1503.dylib:x86_64+0x46d1c)
#2 main main.c:902 (named:x86_64+0x10000ad16)
Thread T5 (tid=4527467, running) created by main thread at:
#0 pthread_create <null>:7953024 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2a9cd)
#1 isc_thread_create thread.c:75 (libisc.1503.dylib:x86_64+0x46d1c)
#2 main main.c:902 (named:x86_64+0x10000ad16)
SUMMARY: ThreadSanitizer: data race dispatch.c:1501 in startrecv