[Mesa-dev] [PATCH 23/25] mesa/glthread: don't set a dispatch table if we aren't the owner

Timothy Arceri tarceri at itsqueeze.com
Tue Mar 7 06:21:35 UTC 2017


From: Gregory Hainaut <gregory.hainaut at gmail.com>

Fix crashes when glxMakeCurrent is called.

Signed-off-by: Gregory Hainaut <gregory.hainaut at gmail.com>
Signed-off-by: Marek Olšák <marek.olsak at amd.com>
---
 src/mesa/main/glthread.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/glthread.c b/src/mesa/main/glthread.c
index 8f300d4..8ee7d8d 100644
--- a/src/mesa/main/glthread.c
+++ b/src/mesa/main/glthread.c
@@ -166,23 +166,30 @@ _mesa_glthread_destroy(struct gl_context *ctx)
     * point, and no batches queued.
     */
    assert(!glthread->batch->used);
    assert(!glthread->batch->next);
    free(glthread->batch);
    assert(!glthread->batch_queue);
 
    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
 _mesa_glthread_flush_batch(struct gl_context *ctx)
 {
    struct glthread_state *glthread = ctx->GLThread;
    struct glthread_batch *batch;
 
    if (!glthread)
       return;
-- 
2.9.3



More information about the mesa-dev mailing list