util/u_queue: Fix data race on num_threads during finish.
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

This should fix a deadlock I saw on
dEQP-EGL.functional.sharing.gles2.multithread.random.programs.link.7 on
radeonsi, where we were waiting on an invalid fence[1] value.  This was
probably because between when we started setting up the fences for
u_queue_finish and when we waited on those fences, a second thread was
created.

Closes: #13738
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36919>
This commit is contained in:
Emma Anholt 2025-08-21 11:20:48 -07:00 committed by Marge Bot
parent 1f79ba9a51
commit d1a6be75db

View file

@ -708,6 +708,7 @@ util_queue_finish(struct util_queue *queue)
queue->create_threads_on_demand = false;
fences = malloc(queue->num_threads * sizeof(*fences));
unsigned num_fences = queue->num_threads;
util_barrier_init(&barrier, queue->num_threads);
for (unsigned i = 0; i < queue->num_threads; ++i) {
@ -718,7 +719,7 @@ util_queue_finish(struct util_queue *queue)
queue->create_threads_on_demand = true;
mtx_unlock(&queue->lock);
for (unsigned i = 0; i < queue->num_threads; ++i) {
for (unsigned i = 0; i < num_fences; ++i) {
util_queue_fence_wait(&fences[i]);
util_queue_fence_destroy(&fences[i]);
}