From a6b7068ff5fbf4694a45a6e07adac5047e574514 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Tue, 23 Apr 2019 12:54:38 +1000 Subject: st/mesa/radeonsi: fix race between destruction of types and shader compilation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 624789e3708c moved the destruction of types out of atexit() and made use of a ref count instead. This is useful for avoiding a crash where drivers such as radeonsi are still compiling in a thread when the app exits and has not called MakeCurrent to change from the current context. While the above scenario is technically an app bug we shouldn't crash. However that change caused another race condition between the shader compilation tread in radeonsi and context teardown functions. This patch makes two changes to fix this new problem: First we explicitly call _mesa_destroy_shader_compiler_types() when destroying the st context rather than calling it indirectly via _mesa_free_context_data(). We do this as we must call it after st_destroy_context_priv() so that we don't destory the glsl types before the compilation threads finish. Next wait for the shader threads to finish in si_destroy_context() this also means we need to call context destroy before destroying the queues in si_destroy_screen(). Fixes: 624789e3708c ("compiler/glsl: handle case where we have multiple users for types") Reviewed-by: Marek Olšák --- src/mesa/drivers/osmesa/osmesa.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/mesa/drivers/osmesa') diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index 44374a2e917..a065161b89e 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -854,7 +854,7 @@ OSMesaCreateContextAttribs(const int *attribList, OSMesaContext sharelist) osmesa->gl_buffer = _mesa_create_framebuffer(osmesa->gl_visual); if (!osmesa->gl_buffer) { _mesa_destroy_visual( osmesa->gl_visual ); - _mesa_free_context_data( &osmesa->mesa ); + _mesa_free_context_data(&osmesa->mesa, true); free(osmesa); return NULL; } @@ -891,7 +891,7 @@ OSMesaCreateContextAttribs(const int *attribList, OSMesaContext sharelist) !_tnl_CreateContext( ctx ) || !_swsetup_CreateContext( ctx )) { _mesa_destroy_visual(osmesa->gl_visual); - _mesa_free_context_data(ctx); + _mesa_free_context_data(ctx, true); free(osmesa); return NULL; } @@ -919,7 +919,7 @@ OSMesaCreateContextAttribs(const int *attribList, OSMesaContext sharelist) if (ctx->Version < version_major * 10 + version_minor) { _mesa_destroy_visual(osmesa->gl_visual); - _mesa_free_context_data(ctx); + _mesa_free_context_data(ctx, true); free(osmesa); return NULL; } @@ -955,7 +955,7 @@ OSMesaDestroyContext( OSMesaContext osmesa ) _mesa_destroy_visual( osmesa->gl_visual ); _mesa_reference_framebuffer( &osmesa->gl_buffer, NULL ); - _mesa_free_context_data( &osmesa->mesa ); + _mesa_free_context_data(&osmesa->mesa, true); free( osmesa ); } } -- cgit v1.2.3