[PATCH xserver] glamor: Fix crash when master gpu is using glamor and another gpu is hotplugged
Hans de Goede
hdegoede at redhat.com
Mon Sep 5 13:39:45 UTC 2016
When a GPU gets hotplugged while X is already running, glamor_egl_init()
gets called and changes the current egl context at a point where glamor
does not expect this.
This causes glamor to e.g. crash in the next glamor_create_pixmap() call
(caled through the master's screen->CreatePixmap), note this is not the
only troublesome entry point I've seen other backtraces when using a
composting window manager.
Adding glamor_make_current calls to all entry points is quite expensive,
so this commit consists of a miminal fix for this problem by restoring the
original egl context when leaving glamor_egl_init() with an error, based
on only usb gpu's getting hotplugged and they do not support glamor.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
glamor/glamor_egl.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 16a20a7..ba26e48 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -731,6 +731,8 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
{
struct glamor_egl_screen_private *glamor_egl;
const char *version;
+ EGLDisplay orig_display;
+ EGLContext orig_context;
EGLint config_attribs[] = {
#ifdef GLAMOR_GLES2
@@ -748,6 +750,9 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
EGL_NONE
};
+ orig_display = eglGetCurrentDisplay();
+ orig_context = eglGetCurrentContext();
+
glamor_identify(0);
glamor_egl = calloc(sizeof(*glamor_egl), 1);
if (glamor_egl == NULL)
@@ -850,6 +855,11 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
error:
glamor_egl_cleanup(glamor_egl);
+ /*
+ * Restore original egl display & context to avoid crashes on
+ * hotplugging USB display devices.
+ */
+ eglMakeCurrent(orig_display, EGL_NO_SURFACE, EGL_NO_SURFACE, orig_context);
return FALSE;
}
--
2.9.3
More information about the xorg-devel
mailing list