[Mesa-dev] [PATCH] st/mesa: call glthread_destroy() before _vbo_DestroyContext()
Timothy Arceri
tarceri at itsqueeze.com
Thu Mar 16 12:12:08 UTC 2017
Otherwise we have a race condition between vbo calls in the
glthread and the _vbo_DestroyContext() call.
This fixes a bunch of piglit crashes.
---
src/mesa/main/context.c | 2 --
src/mesa/state_tracker/st_context.c | 2 ++
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 0a9c65c..8876ca2 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1287,22 +1287,20 @@ fail:
void
_mesa_free_context_data( struct gl_context *ctx )
{
if (!_mesa_get_current_context()){
/* No current context, but we may need one in order to delete
* texture objs, etc. So temporarily bind the context now.
*/
_mesa_make_current(ctx, NULL, NULL);
}
- _mesa_glthread_destroy(ctx);
-
/* unreference WinSysDraw/Read buffers */
_mesa_reference_framebuffer(&ctx->WinSysDrawBuffer, NULL);
_mesa_reference_framebuffer(&ctx->WinSysReadBuffer, NULL);
_mesa_reference_framebuffer(&ctx->DrawBuffer, NULL);
_mesa_reference_framebuffer(&ctx->ReadBuffer, NULL);
_mesa_reference_program(ctx, &ctx->VertexProgram.Current, NULL);
_mesa_reference_program(ctx, &ctx->VertexProgram._Current, NULL);
_mesa_reference_program(ctx, &ctx->VertexProgram._TnlProgram, NULL);
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 869e6e9..ed43dd6 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -585,20 +585,22 @@ void st_destroy_context( struct st_context *st )
st_reference_compprog(st, &st->cp, NULL);
/* release framebuffer surfaces */
for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
pipe_surface_reference(&st->state.framebuffer.cbufs[i], NULL);
}
pipe_surface_reference(&st->state.framebuffer.zsbuf, NULL);
pipe_sampler_view_reference(&st->pixel_xfer.pixelmap_sampler_view, NULL);
pipe_resource_reference(&st->pixel_xfer.pixelmap_texture, NULL);
+ _mesa_glthread_destroy(ctx);
+
_vbo_DestroyContext(ctx);
st_destroy_program_variants(st);
_mesa_free_context_data(ctx);
/* This will free the st_context too, so 'st' must not be accessed
* afterwards. */
st_destroy_context_priv(st, true);
st = NULL;
--
2.9.3
More information about the mesa-dev
mailing list