Bug 97136

Summary: [softpipe] piglit egl-create-context-verify-gl-flavor regression
Product: Mesa Reporter: Vinson Lee <vlee>
Component: Mesa coreAssignee: mesa-dev
Status: RESOLVED FIXED QA Contact: mesa-dev
Severity: normal    
Priority: medium CC: drinkcat, emil.l.velikov, fdo-bugs, mexahotabop
Version: 13.0Keywords: bisected, regression
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
i915 platform: i915 features:

Description Vinson Lee 2016-07-29 20:38:54 UTC
mesa: b107169eef92e740180df468d1eae4cc61a52757 (12.1.0-devel)

$ ./bin/egl-create-context-verify-gl-flavor -auto
info: request an OpenGL 1.0 context
Segmentation fault (core dumped)

(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00000000004011ec in get_gl_version () at piglit/tests/egl/spec/egl_khr_create_context/verify-gl-flavor.c:102
#2  0x0000000000401751 in check_flavor (requested_version=10, requested_api=API_GL_COMPAT) at piglit/tests/egl/spec/egl_khr_create_context/verify-gl-flavor.c:257
#3  0x0000000000401b4e in check_opengl () at piglit/tests/egl/spec/egl_khr_create_context/verify-gl-flavor.c:360
#4  0x00000000004024ac in main (argc=2, argv=0x7fffa9d82f78) at piglit/tests/egl/spec/egl_khr_create_context/verify-gl-flavor.c:491
(gdb) frame 1
#1  0x00000000004011ec in get_gl_version () at piglit/tests/egl/spec/egl_khr_create_context/verify-gl-flavor.c:102
102		version_string = (const char*) my_glGetString(GL_VERSION);
(gdb) print my_glGetString
$1 = (const char *(*)(GLenum)) 0x0

9ee683f877b283020c6f24776236f1145cb7a4ea is the first bad commit
commit 9ee683f877b283020c6f24776236f1145cb7a4ea
Author: Nicolas Boichat <drinkcat@chromium.org>
Date:   Fri Jul 22 11:27:41 2016 +0800

    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>

:040000 040000 e85e5c29d107c99c0c163074ad701d587efe9d70 40574abb1fa0fb3f7cdbedf970815b745d08b0de M	src
bisect run success
Comment 1 Nicolas Boichat 2016-08-04 12:20:12 UTC
This patch https://patchwork.freedesktop.org/patch/102770/ should fix it, can you please try it out?

Comment 2 Vinson Lee 2016-10-31 16:54:41 UTC
commit 4f3f8bb59dd98e39c363fe47a55a7f97e7df9f4b
Author: Nicolas Boichat <drinkcat@chromium.org>
Date:   Wed Aug 3 21:54:22 2016 +0800

    egl/dri2: dri2_initialize: Do not reference-count TestOnly display
    In the case where dri2_initialize is called with a TestOnly display,
    the display is not actually initialized, so dri2_egl_display always
    fails, and we cannot do any reference counting.
    Fixes piglit spec@egl_khr_create_context@verify gl flavor (reproducible
    Fixes: 9ee683f877 (egl/dri2: Add reference count for dri2_egl_display)
    Cc: "12.0" <mesa-stable@lists.freedesktop.org>
    Reported-by: Michel Dänzer <michel@daenzer.net>
    Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
    Reviewed-by: Emil Velikov <emil.velikov@collabora.com>

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.