ThreadSanitizer: data race in zonemgr_keymgmt_delete()
See this failed job: https://gitlab.isc.org/isc-projects/bind9/-/jobs/2982394
The TSAN report is here: tsan.named.32229.
This was most likely uncovered after #3727 (closed) was fixed, as before that the code under the "Delete the entry" comment in zone.c:zonemgr_keymgmt_delete() (see below) wasn't being executed:
if (dns_name_equal(kfio->name, &zone->origin)) {
unsigned int count;
count = atomic_fetch_sub_relaxed(&kfio->count, 1) - 1;
if (count > 0) {
/* Keep the entry. */
break;
}
/* Delete the entry. */
if (prev == NULL) {
mgmt->table[hash] = kfio->next;
} else {
prev->next = kfio->next;
}
isc_mutex_destroy(&kfio->lock);
isc_mem_put(mgmt->mctx, kfio, sizeof(*kfio));
atomic_fetch_sub_relaxed(&mgmt->count, 1); // <---- the report is here
break;
}
Edited by Arаm Sаrgsyаn