From 98718b3b4b1604935aca952477b7ac97dc32557d Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 6 Apr 2022 15:52:24 +1000 Subject: [PATCH] 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 --- lib/isc/timer.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/isc/timer.c b/lib/isc/timer.c index b2f6c0b1c1..68984fd5e9 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); - } } }