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>
This commit is contained in:
@@ -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.
|
||||
|
Reference in New Issue
Block a user