Mesa (staging/19.2): util/u_queue: skip util_queue_finish if num_threads is 0
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Oct 25 17:02:20 UTC 2019
Module: Mesa
Branch: staging/19.2
Commit: 340849f311eea4d0d17267da9f1f6a153695f19f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=340849f311eea4d0d17267da9f1f6a153695f19f
Author: Marek Olšák <marek.olsak at amd.com>
Date: Wed Oct 23 21:01:38 2019 -0400
util/u_queue: skip util_queue_finish if num_threads is 0
This fixes a deadlock in pthread_barrier_destroy.
Cc: 19.1 19.2 <mesa-stable at lists.freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
(cherry picked from commit c2efd2cbfb19808cd4bf5f2f0cf62455f80f1a2f)
---
src/util/u_queue.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/util/u_queue.c b/src/util/u_queue.c
index 81225a80faa..9a51b71cfe1 100644
--- a/src/util/u_queue.c
+++ b/src/util/u_queue.c
@@ -637,6 +637,13 @@ util_queue_finish(struct util_queue *queue)
* wait for it exclusively.
*/
mtx_lock(&queue->finish_lock);
+
+ /* The number of threads can be changed to 0, e.g. by the atexit handler. */
+ if (!queue->num_threads) {
+ mtx_unlock(&queue->finish_lock);
+ return;
+ }
+
fences = malloc(queue->num_threads * sizeof(*fences));
util_barrier_init(&barrier, queue->num_threads);
More information about the mesa-commit
mailing list