From 993612193575f5f218af52c4ed7525e15083548e Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Sun, 26 Feb 2017 02:44:06 +0200 Subject: [PATCH] gallium/u_queue: fix a crash with atexit handlers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Commit 4aea8fe ("gallium/u_queue: fix random crashes when the app calls exit()") added a atexit handler which calls util_queue_killall_and_wait() for each queue to stop the threads. However the app is also free to use atexit handlers to clean up things, leading to util_queue_destroy() call which will also call util_queue_killall_and_wait() for the same queue again, causing threads being joined twice, and that is undefined. This happens with libglut, for example. A simple fix is to just set num_threads to 0 as there are no more valid threads after util_queue_killall_and_wait() returns. Fixes: 4aea8fe "gallium/u_queue: fix random crashes when the app calls exit()" Signed-off-by: Grazvydas Ignotas Signed-off-by: Marek Olšák --- src/gallium/auxiliary/util/u_queue.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/auxiliary/util/u_queue.c b/src/gallium/auxiliary/util/u_queue.c index 386dc4a9946..c51b6213c8c 100644 --- a/src/gallium/auxiliary/util/u_queue.c +++ b/src/gallium/auxiliary/util/u_queue.c @@ -272,6 +272,7 @@ util_queue_killall_and_wait(struct util_queue *queue) for (i = 0; i < queue->num_threads; i++) pipe_thread_wait(queue->threads[i]); + queue->num_threads = 0; } void -- 2.30.2