mesa: reorder st context teardown

some gnome tests are seeing this:

==4579== Invalid read of size 4
==4579==    at 0x161B28FB: UnknownInlinedFun (simple_mtx.h:106)
==4579==    by 0x161B28FB: st_save_zombie_sampler_view (st_context.c:213)
==4579==    by 0x161D762A: st_texture_release_all_sampler_views.part.0 (st_sampler_view.c:272)
==4579==    by 0x161D7CB6: st_texture_release_all_sampler_views (st_sampler_view.c:258)
==4579==    by 0x161D7CB6: st_delete_texture_sampler_views (st_sampler_view.c:292)
==4579==    by 0x16191B9E: _mesa_delete_texture_object (texobj.c:523)
==4579==    by 0x16191CDC: _mesa_reference_texobj_ (texobj.c:637)
==4579==    by 0x1619632F: _mesa_reference_texobj (texobj.h:92)
==4579==    by 0x1619632F: _mesa_free_texture_data (texstate.c:1114)
==4579==    by 0x162EEE1D: _mesa_free_context_data (context.c:1155)
==4579==    by 0x161B3C0F: st_destroy_context (st_context.c:999)
==4579==    by 0x160F155A: dri_destroy_context (dri_context.c:277)
==4579==    by 0x1603C371: dri2_destroy_context (egl_dri2.c:1592)
==4579==    by 0x1602EBF5: eglDestroyContext (eglapi.c:918)
==4579==    by 0x502DF3C: gdk_gl_context_dispose (gdkglcontext.c:211)
==4579==  Address 0x34dc9b08 is 7,016 bytes inside an unallocated block of size 10,336 in arena "client"
==4579==

It appears we destroy the mutex and zombie objects, but freeing
context data seems to add them back.

This might not be the complete answer.

Cc: mesa-stable
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28565>
This commit is contained in:
Dave Airlie 2024-04-04 11:44:44 +10:00 committed by Marge Bot
parent 067bbf9301
commit f8e48b561e
1 changed files with 5 additions and 5 deletions

View File

@ -983,17 +983,17 @@ 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.
*/
_mesa_free_context_data(ctx, false);
st_context_free_zombie_objects(st);
simple_mtx_destroy(&st->zombie_sampler_views.mutex);
simple_mtx_destroy(&st->zombie_shaders.mutex);
/* This will free the st_context too, so 'st' must not be accessed
* afterwards. */
st_destroy_context_priv(st, true);