[Mesa-dev] [PATCH] egl: Fix segfault due to bad generation of EGLConfigs

Chad Versace chad.versace at linux.intel.com
Mon Oct 8 14:41:53 PDT 2012


Fixes segfault in intelCreateBuffer when running gles2conform.
To reproduce the segfault, execute `GTF` with no arguments.

Commit 7dc0be8 incidentally changed the Intel driver to to list, in
dri2_egl_display::driver_configs, the double-buffered variant of each
__DRIconfig *before* the single-buffered variant. This exposed a bug in
dri2_add_config() that caused two distinct EGLConfig's to be constructed,
one for the double-buffered __DRIconfig and one the single-buffered
__DRIconfig, despite that the property of being single or double-buffered
does not belong to EGLConfig's.

The bug's root cause was that the values for _EGLConfig::MinSwapInterval
and ::MaxSwapInterval were bound too late. This caused dri2_match_config()
to incorrectly reject the match between the two __DRIconfig's.  The fix is
to bind the values as early as possible, during _eglInitConfig.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=55443
Reported-by: Lu Hua <huax.lu at intel.com>
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---

A separate change is needed to fix Piglit's GTF integration. You need to
change in gtf.tests the hard-coded '-id=10' to '-id=5'.

 src/egl/drivers/dri2/egl_dri2.c | 5 -----
 src/egl/main/eglconfig.c        | 9 +++++++++
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 4b58c35..9d6b2cf 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -261,11 +261,6 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
 
    if (double_buffer) {
       surface_type &= ~EGL_PIXMAP_BIT;
-
-      if (dri2_dpy->swap_available) {
-         conf->base.MinSwapInterval = 0;
-         conf->base.MaxSwapInterval = 1000; /* XXX arbitrary value */
-      }
    }
 
    conf->base.SurfaceType |= surface_type;
diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
index e1d53da..ee97d41 100644
--- a/src/egl/main/eglconfig.c
+++ b/src/egl/main/eglconfig.c
@@ -66,6 +66,15 @@ _eglInitConfig(_EGLConfig *conf, _EGLDisplay *dpy, EGLint id)
    conf->TransparentType = EGL_NONE;
    conf->NativeVisualType = EGL_NONE;
    conf->ColorBufferType = EGL_RGB_BUFFER;
+
+   /* There does not exist such a thing as a double-buffered or
+    * single-buffered EGLConfig. (See Table 3.4 of the EGL 1.4 spec, which
+    * lists all EGLConfig attribute)s. The property of being single or
+    * double-buffered belongs to the EGLSurface. (See the documentation for
+    * EGL_RENDER_BUFFER in section 3.5.1 of the EGL 1.4 spec).
+    */
+   conf->MinSwapInterval = 0;
+   conf->MaxSwapInterval = 1000; /*arbitrary*/
 }
 
 
-- 
1.7.11.4



More information about the mesa-dev mailing list