From b1026dd4c122b35706a65dba72f7739e2f3f1c9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Mon, 29 Aug 2022 13:42:14 +0200 Subject: [PATCH] Add missing isc_refcount_destroy() for isc__nmsocket_t The destructor for the isc__nmsocket_t was missing call to the isc_refcount_destroy() on the reference counter, which might lead to spurious ThreadSanitizer data race warnings if we ever change the acquire-release memory order in the isc_refcount_decrement(). --- lib/isc/netmgr/netmgr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index 5f3a17f12c..14f5d2e832 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -665,6 +665,8 @@ nmsocket_cleanup(isc_nmsocket_t *sock, bool dofree FLARG) { "\n", sock, isc_refcount_current(&sock->references)); + isc_refcount_destroy(&sock->references); + isc__nm_decstats(sock, STATID_ACTIVE); atomic_store(&sock->destroying, true); @@ -675,7 +677,9 @@ nmsocket_cleanup(isc_nmsocket_t *sock, bool dofree FLARG) { * so we can clean up and free the children. */ for (size_t i = 0; i < sock->nchildren; i++) { - if (!atomic_load(&sock->children[i].destroying)) { + REQUIRE(!atomic_load(&sock->children[i].destroying)); + if (isc_refcount_decrement( + &sock->children[i].references)) { nmsocket_cleanup(&sock->children[i], false FLARG_PASS); }