[PATCH v2 xserver] glamor: Fix crash when master gpu is using glamor and another gpu is hotplugged

Hans de Goede hdegoede at redhat.com
Thu Sep 8 08:20:37 UTC 2016


When a GPU gets hotplugged while X is already running, glamor_egl_init()
gets called and changes the current egl context, without updating
lastGLContext, potentially causing the next glamor call on another GPU to
run in the wrong context.

This causes glamor to e.g. crash in the next glamor_create_pixmap() call
(called through the master's screen->CreatePixmap), note this is not the
only troublesome entry point I've seen other backtraces when using a
compositing window manager.

Set lastGLContext to NULL to force the next glamor_make_current() call
to set the right context.

Note that we cannot use glamor_make_current() here to replace the
eglMakeCurrent() call and update lastGLContext for us because
glamor_make_current takes a glamor_priv struct as argument and that
has not been created yet when glamor_egl_init() gets called.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
Changes in v2:
-Set lastGLContext to NULL instead of saving and restoring the current context
---
 glamor/glamor_egl.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 16a20a7..2b9e0e1 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -703,6 +703,11 @@ static void glamor_egl_cleanup(struct glamor_egl_screen_private *glamor_egl)
     if (glamor_egl->display != EGL_NO_DISPLAY) {
         eglMakeCurrent(glamor_egl->display,
                        EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+        /*
+         * Force the next glamor_make_current call to update the context
+         * (on hot unplug another GPU may still be using glamor)
+         */
+        lastGLContext = NULL;
         eglTerminate(glamor_egl->display);
     }
 #ifdef GLAMOR_HAS_GBM
@@ -831,6 +836,11 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
                    "Failed to make EGL context current\n");
         goto error;
     }
+    /*
+     * Force the next glamor_make_current call to set the right context
+     * (in case of multiple GPUs using glamor)
+     */
+    lastGLContext = NULL;
 #ifdef GLAMOR_HAS_GBM
     if (epoxy_has_egl_extension(glamor_egl->display,
                                 "EGL_KHR_gl_texture_2D_image") &&
-- 
2.9.3



More information about the xorg-devel mailing list