summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorErico Nunes <nunes.erico@gmail.com>2022-12-27 12:32:07 +0100
committerMarge Bot <emma+marge@anholt.net>2023-01-02 13:50:52 +0000
commit46a493a2f00f70ec2cd3c5e9403ddf508bd20118 (patch)
tree7dc156f75f0e8367129e13066ac045c8a7d7c459 /src/mesa/state_tracker
parent1174ab6d56e779529a0ff1c01b78f49ce103eadf (diff)
st/mesa: Fix free of non-shareable shaders on context destroy
On drivers that do not set PIPE_CAP_SHAREABLE_SHADERS, st_destroy_program_variants() may reach st_save_zombie_shader() which accesses st->zombie_shaders.mutex. Destroying st->zombie_shaders.mutex before destroying program variants may result in an invalid access in a multiple context scenario for those drivers. Move the mutex destroy call to after program variants destroy so that it doesn't hit a deadlock on context destroy. Signed-off-by: Erico Nunes <nunes.erico@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20458>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_context.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 7722eb6cc81..7d50658f660 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -947,11 +947,6 @@ st_destroy_context(struct st_context *st)
}
}
- st_context_free_zombie_objects(st);
-
- simple_mtx_destroy(&st->zombie_sampler_views.mutex);
- simple_mtx_destroy(&st->zombie_shaders.mutex);
-
st_release_program(st, &st->fp);
st_release_program(st, &st->gp);
st_release_program(st, &st->vp);
@@ -979,6 +974,11 @@ st_destroy_context(struct st_context *st)
st_destroy_program_variants(st);
+ st_context_free_zombie_objects(st);
+
+ simple_mtx_destroy(&st->zombie_sampler_views.mutex);
+ simple_mtx_destroy(&st->zombie_shaders.mutex);
+
/* Do not release debug_output yet because it might be in use by other threads.
* These threads will be terminated by _mesa_free_context_data and
* st_destroy_context_priv.