ThreadSanitizer: data race rbtdb.c:5193 in detachnode
Binary: named
Commits: c9e358fb
Tests: dnssec
WARNING: ThreadSanitizer: data race (pid=33568)
Read of size 2 at 0x7b20000236e8 by thread T8 (mutexes: write M67733):
#0 detachnode rbtdb.c:5193 (libdns.1503.dylib:x86_64+0xb6e29)
#1 rdataset_disassociate rbtdb.c:8372 (libdns.1503.dylib:x86_64+0xc0070)
#2 dns_rdataset_disassociate rdataset.c:118 (libdns.1503.dylib:x86_64+0x11fe49)
#3 validate_answer validator.c:1602 (libdns.1503.dylib:x86_64+0x182c10)
#4 validator_start validator.c:3157 (libdns.1503.dylib:x86_64+0x180193)
#5 run task.c:1134 (libisc.1503.dylib:x86_64+0x3b141)
Previous write of size 2 at 0x7b20000236e8 by thread T5 (mutexes: write M1022452887919270936, write M922529271186985760):
#0 add32 rbtdb.c:6189 (libdns.1503.dylib:x86_64+0xbe862)
#1 addrdataset rbtdb.c:6591 (libdns.1503.dylib:x86_64+0xb991c)
#2 dns_db_addrdataset db.c:744 (libdns.1503.dylib:x86_64+0x2c14e)
#3 validated resolver.c:5710 (libdns.1503.dylib:x86_64+0x14b550)
#4 run task.c:1134 (libisc.1503.dylib:x86_64+0x3b141)
Location is heap block of size 116 at 0x7b2000023680 allocated by thread T8:
#0 malloc <null>:9011392 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x4e65a)
#1 default_memalloc mem.c:685 (libisc.1503.dylib:x86_64+0x2200f)
#2 isc___mem_allocate mem.c:598 (libisc.1503.dylib:x86_64+0x22e6c)
#3 isc___mem_get mem.c:2387 (libisc.1503.dylib:x86_64+0x22487)
#4 isc__mem_get mem.c:2365 (libisc.1503.dylib:x86_64+0x1d18e)
#5 create_node rbt.c:2189 (libdns.1503.dylib:x86_64+0xaaa35)
#6 dns_rbt_addnode rbt.c:1146 (libdns.1503.dylib:x86_64+0xaa5f8)
#7 findnodeintree rbtdb.c:2739 (libdns.1503.dylib:x86_64+0xc872a)
#8 findnode rbtdb.c:2784 (libdns.1503.dylib:x86_64+0xb518b)
#9 dns_db_findnode db.c:447 (libdns.1503.dylib:x86_64+0x2afb8)
#10 validated resolver.c:5620 (libdns.1503.dylib:x86_64+0x14aed1)
#11 run task.c:1134 (libisc.1503.dylib:x86_64+0x3b141)
Mutex M67733 (0x7b740001fe18) created at:
#0 pthread_mutex_init <null>:9011248 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2b9a3)
#1 isc__mutex_init mutex.c:286 (libisc.1503.dylib:x86_64+0x57f99)
#2 dns_validator_create validator.c:3261 (libdns.1503.dylib:x86_64+0x17f987)
#3 valcreate resolver.c:868 (libdns.1503.dylib:x86_64+0x149992)
#4 resquery_response resolver.c:6380 (libdns.1503.dylib:x86_64+0x14280d)
#5 run task.c:1134 (libisc.1503.dylib:x86_64+0x3b141)
Mutex M1022452887919270936 is already destroyed.
Mutex M922529271186985760 is already destroyed.
Thread T8 (tid=5596916, running) created by main thread at:
#0 pthread_create <null>:9011440 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2a9cd)
#1 isc_thread_create thread.c:75 (libisc.1503.dylib:x86_64+0x580a1)
#2 isc_taskmgr_create task.c:1410 (libisc.1503.dylib:x86_64+0x3a630)
#3 main main.c:902 (named:x86_64+0x10000df36)
Thread T5 (tid=5596913, running) created by main thread at:
#0 pthread_create <null>:9011440 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2a9cd)
#1 isc_thread_create thread.c:75 (libisc.1503.dylib:x86_64+0x580a1)
#2 isc_taskmgr_create task.c:1410 (libisc.1503.dylib:x86_64+0x3a630)
#3 main main.c:902 (named:x86_64+0x10000df36)
SUMMARY: ThreadSanitizer: data race rbtdb.c:5193 in detachnode
This looks eerily similar to #1347 (closed), and it might be related, but in the first case, TSAN complains about nodelock
access, and here, it complains about nodelock = &rbtdb->node_locks[node->locknum];
access, from:
da1e0ac7424 (Automatic Updater 2008-01-31 23:47:06 +0000 5192) node = (dns_rbtnode_t *)(*targetp);
da1e0ac7424 (Automatic Updater 2008-01-31 23:47:06 +0000 5193) nodelock = &rbtdb->node_locks[node->locknum];
da1e0ac7424 (Automatic Updater 2008-01-31 23:47:06 +0000 5194)
da1e0ac7424 (Automatic Updater 2008-01-31 23:47:06 +0000 5195) NODE_LOCK(&nodelock->lock, isc_rwlocktype_read);
da1e0ac7424 (Automatic Updater 2008-01-31 23:47:06 +0000 5196)
da1e0ac7424 (Automatic Updater 2008-01-31 23:47:06 +0000 5197) if (decrement_reference(rbtdb, node, 0, isc_rwlocktype_read,
994e656977b (Ondřej Surý 2018-04-17 08:29:14 -0700 5198) isc_rwlocktype_none, false)) {
da1e0ac7424 (Automatic Updater 2008-01-31 23:47:06 +0000 5199) if (isc_refcount_current(&nodelock->references) == 0 &&
da1e0ac7424 (Automatic Updater 2008-01-31 23:47:06 +0000 5200) nodelock->exiting) {
994e656977b (Ondřej Surý 2018-04-17 08:29:14 -0700 5201) inactive = true;
da1e0ac7424 (Automatic Updater 2008-01-31 23:47:06 +0000 5202) }
da1e0ac7424 (Automatic Updater 2008-01-31 23:47:06 +0000 5203) }
da1e0ac7424 (Automatic Updater 2008-01-31 23:47:06 +0000 5204)
da1e0ac7424 (Automatic Updater 2008-01-31 23:47:06 +0000 5205) NODE_UNLOCK(&nodelock->lock, isc_rwlocktype_read);
da1e0ac7424 (Automatic Updater 2008-01-31 23:47:06 +0000 5206)