From 541872bf3b1d7d5d30a2aaeb0d19f36829711161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Tue, 30 Oct 2018 07:09:58 +0000 Subject: [PATCH 1/3] Destroy task first when destroying rpzs. When freeing rpzs structures we need to kill the updater task first. Otherwise we might race with the updater and there might be a crash on shutdown. --- lib/dns/rpz.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index 38fd3bd2cd..00751923e2 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -2148,7 +2148,12 @@ dns_rpz_detach_rpzs(dns_rpz_zones_t **rpzsp) { *rpzsp = NULL; if (isc_refcount_decrement(&rpzs->refs) == 1) { - isc_refcount_destroy(&rpzs->refs); + /* + * Destroy the task first, so that nothing runs + * in the background that might race with us. + */ + isc_task_destroy(&rpzs->updater); + /* * Forget the last of view's rpz machinery after * the last reference. @@ -2178,7 +2183,7 @@ dns_rpz_detach_rpzs(dns_rpz_zones_t **rpzsp) { } DESTROYLOCK(&rpzs->maint_lock); isc_rwlock_destroy(&rpzs->search_lock); - isc_task_destroy(&rpzs->updater); + isc_refcount_destroy(&rpzs->refs); isc_mem_putanddetach(&rpzs->mctx, rpzs, sizeof(*rpzs)); } } From c1d111cd2e95393d60b0431935f8d03e4e2cc426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Tue, 30 Oct 2018 13:41:07 +0100 Subject: [PATCH 2/3] Destroy task first when destroying catzs. When freeing catzs structures we need to kill the updater task first. Otherwise we might race with the updater and there might be a crash on shutdown. --- lib/dns/catz.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dns/catz.c b/lib/dns/catz.c index 848e42a2b5..ca42a55f7d 100644 --- a/lib/dns/catz.c +++ b/lib/dns/catz.c @@ -795,7 +795,7 @@ dns_catz_catzs_detach(dns_catz_zones_t **catzsp) { *catzsp = NULL; if (isc_refcount_decrement(&catzs->refs) == 1) { - isc_refcount_destroy(&catzs->refs); + isc_task_destroy(&catzs->updater); DESTROYLOCK(&catzs->lock); if (catzs->zones != NULL) { isc_ht_iter_t *iter = NULL; @@ -815,7 +815,7 @@ dns_catz_catzs_detach(dns_catz_zones_t **catzsp) { INSIST(isc_ht_count(catzs->zones) == 0); isc_ht_destroy(&catzs->zones); } - isc_task_destroy(&catzs->updater); + isc_refcount_destroy(&catzs->refs); isc_mem_putanddetach(&catzs->mctx, catzs, sizeof(*catzs)); } } From 19c4fe93c4ca1a73eb482af0963cba67979d6605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Tue, 30 Oct 2018 07:14:57 +0000 Subject: [PATCH 3/3] CHANGES entry --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index 8e6d993723..79d4b4e664 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +5073. [bug] Destroy a task first when destroying rpzs and catzs. + [GL #84] + 5072. [bug] Add unit tests for isc_buffer_copyregion() and fix its behavior for auto-reallocated buffers. [GL #644]