From: Ondřej Surý Date: Mon, 6 Dec 2021 10:10:17 +0000 (+0100) Subject: Stop leaking mutex in nmworker and cond in nm socket X-Git-Tag: v9.17.22~49^2~1 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=57d0fabaddf0e7ac297a046b084df8fb22d54d51;p=thirdparty%2Fbind9.git Stop leaking mutex in nmworker and cond in nm socket On FreeBSD, the pthread primitives are not solely allocated on stack, but part of the object lives on the heap. Missing pthread_*_destroy causes the heap memory to grow and in case of fast lived object it's possible to run out-of-memory. Properly destroy the leaking mutex (worker->lock) and the leaking condition (sock->cond). --- diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index 13168683e11..51045521a1d 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -379,6 +379,7 @@ nm_destroy(isc_nm_t **mgr0) { isc_mem_put(mgr->mctx, ievent, sizeof(*ievent)); } isc_condition_destroy(&worker->cond_prio); + isc_mutex_destroy(&worker->lock); r = uv_loop_close(&worker->loop); INSIST(r == 0); @@ -1271,8 +1272,9 @@ nmsocket_cleanup(isc_nmsocket_t *sock, bool dofree FLARG) { sock->ah_size * sizeof(sock->ah_frees[0])); isc_mem_put(sock->mgr->mctx, sock->ah_handles, sock->ah_size * sizeof(sock->ah_handles[0])); - isc_mutex_destroy(&sock->lock); isc_condition_destroy(&sock->scond); + isc_condition_destroy(&sock->cond); + isc_mutex_destroy(&sock->lock); #if HAVE_LIBNGHTTP2 isc__nm_tls_cleanup_data(sock); isc__nm_http_cleanup_data(sock);