From: Mark Andrews Date: Wed, 6 Apr 2022 05:52:24 +0000 (+1000) Subject: Unlink the timer event before trying to purge it X-Git-Tag: v9.19.0~12^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=98718b3b4b1604935aca952477b7ac97dc32557d;p=thirdparty%2Fbind9.git Unlink the timer event before trying to purge it as far as I can determine the order of operations is not important. *** CID 351372: Concurrent data access violations (ATOMICITY) /lib/isc/timer.c: 227 in timer_purge() 221 LOCK(&timer->lock); 222 if (!purged) { 223 /* 224 * The event has already been executed, but not 225 * yet destroyed. 226 */ >>> CID 351372: Concurrent data access violations (ATOMICITY) >>> Using an unreliable value of "event" inside the second locked section. If the data that "event" depends on was changed by another thread, this use might be incorrect. 227 timerevent_unlink(timer, event); 228 } 229 } 230 } 231 232 void --- diff --git a/lib/isc/timer.c b/lib/isc/timer.c index b2f6c0b1c1e..68984fd5e95 100644 --- a/lib/isc/timer.c +++ b/lib/isc/timer.c @@ -215,17 +215,10 @@ timer_purge(isc_timer_t *timer) { isc_timerevent_t *event = NULL; while ((event = ISC_LIST_HEAD(timer->active)) != NULL) { + timerevent_unlink(timer, event); UNLOCK(&timer->lock); - bool purged = isc_task_purgeevent(timer->task, - (isc_event_t *)event); + (void)isc_task_purgeevent(timer->task, (isc_event_t *)event); LOCK(&timer->lock); - if (!purged) { - /* - * The event has already been executed, but not - * yet destroyed. - */ - timerevent_unlink(timer, event); - } } }