mesa/glthread: don't set a dispatch table if we aren't the owner
authorGregory Hainaut <gregory.hainaut@gmail.com>
Mon, 13 Feb 2017 18:14:28 +0000 (19:14 +0100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Thu, 16 Mar 2017 03:14:19 +0000 (14:14 +1100)
Fix crashes when glxMakeCurrent is called.

Signed-off-by: Gregory Hainaut <gregory.hainaut@gmail.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
Tested-by: Mike Lothian <mike@fireburn.co.uk>
src/mesa/main/glthread.c

index 8f300d4..8ee7d8d 100644 (file)
@@ -173,9 +173,16 @@ _mesa_glthread_destroy(struct gl_context *ctx)
    free(glthread);
    ctx->GLThread = NULL;
 
-   /* Remove ourselves from the dispatch table. */
-   ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
-   _glapi_set_dispatch(ctx->CurrentClientDispatch);
+   /* Remove ourselves from the dispatch table except if another ctx/thread
+    * already installed a new dispatch table.
+    *
+    * Typically glxMakeCurrent will bind a new context (install new table) then
+    * old context might be deleted.
+    */
+   if (_glapi_get_dispatch() == ctx->MarshalExec) {
+       ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
+       _glapi_set_dispatch(ctx->CurrentClientDispatch);
+   }
 }
 
 void