From 22bc882e5b03650179d16d3c2726c04028e56f0b Mon Sep 17 00:00:00 2001 From: Giuliano Belinassi Date: Wed, 10 Apr 2024 16:11:25 -0300 Subject: [PATCH] Fix race condition on process listing Previously the process listing had a race condition where it could deallocate the queue before the process discovery thread ended its job. This commit fix this by checking if the thread ended before destroying the queue. Signed-off-by: Giuliano Belinassi --- tools/patches.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/patches.c b/tools/patches.c index cea15241..1da0538d 100644 --- a/tools/patches.c +++ b/tools/patches.c @@ -184,10 +184,11 @@ process_list_end(struct ulp_process_iterator *it) { if (it->now == NULL) { release_ulp_process(it->last); - producer_consumer_delete(it->pcqueue); if (enable_threading) { + /* Make sure the threads stopped before destroying the queue. */ pthread_join(process_list_thread, NULL); } + producer_consumer_delete(it->pcqueue); /* In case threads were disabled because of some special case, then enable it now. */