]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Acquire qpmulti->mutex during destruction
authorTony Finch <fanf@isc.org>
Wed, 17 May 2023 09:57:16 +0000 (10:57 +0100)
committerTony Finch <fanf@isc.org>
Sat, 20 May 2023 07:26:21 +0000 (07:26 +0000)
Thread sanitizer warns that parts of the qp-trie are accessed
both with and without the mutex; the unlocked accesses happen during
destruction, so they should be benign, but there's no harm locking
anyway to convince tsan it is clean.

Also, ensure .tsan-suppress and .tsan-suppress-extra are in sync.

.tsan-suppress-extra
lib/dns/qp.c

index 0f598bf36b3cc1a97b240e79785134a18bebf2f4..2e31db7e26357a0fe37f105ec4c9eb90caa2966b 100644 (file)
@@ -3,5 +3,5 @@ called_from_lib:libfstrm.so
 called_from_lib:libdummyrpz.so
 # be more selective with liburcu
 race:rcu_barrier
-race:rcu_memb_barrier
+race:rcu_*_barrier
 thread:*
index 10d19e1b1b29d3c9070e15529f0949f89fc7806f..afa513f5599a2cd1c1233a69a5f7069fe11f9a08 100644 (file)
@@ -1431,14 +1431,22 @@ static void
 qpmulti_destroy_cb(struct rcu_head *arg) {
        qp_rcuctx_t *rcuctx = isc_urcu_container(arg, qp_rcuctx_t, rcu_head);
        REQUIRE(QPRCU_VALID(rcuctx));
+       /* only nonzero for reclaim_chunks_cb() */
+       REQUIRE(rcuctx->count == 0);
+
        dns_qpmulti_t *multi = rcuctx->multi;
        REQUIRE(QPMULTI_VALID(multi));
+
+       /* reassure thread sanitizer */
+       LOCK(&multi->mutex);
+
        dns_qp_t *qp = &multi->writer;
        REQUIRE(QP_VALID(qp));
 
-       REQUIRE(rcuctx->count == 0);
-
        destroy_guts(qp);
+
+       UNLOCK(&multi->mutex);
+
        isc_mutex_destroy(&multi->mutex);
        isc_mem_putanddetach(&rcuctx->mctx, rcuctx,
                             STRUCT_FLEX_SIZE(rcuctx, chunk, rcuctx->count));