summaryrefslogtreecommitdiffstats
path: root/src/egl/drivers/dri2/egl_dri2.h
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2016-07-22 11:27:41 +0800
committerEmil Velikov <emil.l.velikov@gmail.com>2016-07-28 14:08:25 +0100
commit9ee683f877b283020c6f24776236f1145cb7a4ea (patch)
tree77d2828fcd2bd7ddf927eae5b8e6ce1f69122096 /src/egl/drivers/dri2/egl_dri2.h
parent8431c0e9d4bae63bf65b94751a89d10a63aebf64 (diff)
downloadexternal_mesa3d-9ee683f877b283020c6f24776236f1145cb7a4ea.zip
external_mesa3d-9ee683f877b283020c6f24776236f1145cb7a4ea.tar.gz
external_mesa3d-9ee683f877b283020c6f24776236f1145cb7a4ea.tar.bz2
egl/dri2: Add reference count for dri2_egl_display
android.opengl.cts.WrapperTest#testGetIntegerv1 CTS test calls eglTerminate, followed by eglReleaseThread. A similar case is observed in this bug: https://bugs.freedesktop.org/show_bug.cgi?id=69622, where the test calls eglTerminate, then eglMakeCurrent(dpy, NULL, NULL, NULL). With the current code, dri2_dpy structure is freed on eglTerminate call, so the display is not initialized when eglReleaseThread calls MakeCurrent with NULL parameters, to unbind the context, which causes a a segfault in drv->API.MakeCurrent (dri2_make_current), either in glFlush or in a latter call. eglTerminate specifies that "If contexts or surfaces associated with display is current to any thread, they are not released until they are no longer current as a result of eglMakeCurrent." However, to properly free the current context/surface (i.e., call glFlush, unbindContext, driDestroyContext), we still need the display vtbl (and possibly an active dri dpy connection). Therefore, we add some reference counter to dri2_egl_display, to make sure the structure is kept allocated as long as it is required. One drawback of this is that eglInitialize may not completely reinitialize the display (if eglTerminate was called with a current context), however, this seems to meet the EGL spec quite well, and does not permanently leak any context/display even for incorrectly written apps. Cc: "12.0" <mesa-stable@lists.freedesktop.org> Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Diffstat (limited to 'src/egl/drivers/dri2/egl_dri2.h')
-rw-r--r--src/egl/drivers/dri2/egl_dri2.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 317de06..4577875 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -177,6 +177,10 @@ struct dri2_egl_display
const __DRI2interopExtension *interop;
int fd;
+ /* dri2_initialize/dri2_terminate increment/decrement this count, so does
+ * dri2_make_current (tracks if there are active contexts/surfaces). */
+ int ref_count;
+
int own_device;
int invalidate_available;
int min_swap_interval;