Created attachment 53286 [details]
Testcases for context creation in combination with glXCreateWindow; use attached Makefile for building
00:02.1 Display controller: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller (rev 07) (i965)
glxinfo | grep renderer:
OpenGL renderer string: Mesa DRI Mobile Intel® GM45 Express Chipset
If a OpenGL context is created indirect, glXCreateNewContext segfaults if created on a GLXWindow created with glXCreateWindow. Direct context creation on glXCreateWindow created drawable works. As does creating direct and indirect context on the plain XWindow, i.e. no intermediary GLXWindow drawable.
See attached testcase program for testing.
Created attachment 53288 [details]
Makefile for the testcases
Sorry no one has ever investigated your bug. I can reproduce with current Mesa:
Starting program: /home/mattst88/Downloads/indirect_context_using_glXCreateWindow
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Red Bits: 8, Green Bits: 8, Blue Bits: 8, Alpha Bits: 8, Depth Bits: 24
Context is created indirect
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff40d0be2 in intel_dri2_flush_with_flags (cPriv=0x61, dPriv=0x632790, flags=3, reason=__DRI2_THROTTLE_SWAPBUFFER)
171 struct brw_context *brw = cPriv->driverPrivate;
#0 0x00007ffff40d0be2 in intel_dri2_flush_with_flags (cPriv=0x61, dPriv=0x632790, flags=3, reason=__DRI2_THROTTLE_SWAPBUFFER)
#1 0x00007ffff766f231 in loader_dri3_flush (draw=0x613ed8, flags=3, throttle_reason=__DRI2_THROTTLE_SWAPBUFFER) at ../../../mesa/src/loader/loader_dri3_helper.c:458
#2 0x00007ffff766837c in glx_dri3_flush_drawable (draw=0x613ed8, flags=3) at ../../../mesa/src/glx/dri3_glx.c:148
#3 0x00007ffff766f9ac in loader_dri3_swap_buffers_msc (draw=0x613ed8, target_msc=0, divisor=0, remainder=0, flush_flags=3, force_copy=false)
#4 0x00007ffff7668d91 in dri3_swap_buffers (pdraw=0x613ea0, target_msc=0, divisor=0, remainder=0, flush=1) at ../../../mesa/src/glx/dri3_glx.c:521
#5 0x00007ffff761e5eb in glXSwapBuffers (dpy=0x604010, drawable=25165827) at ../../../mesa/src/glx/glxcmds.c:843
#6 0x000000000040207f in redrawTheWindow () at glXCreateWindow_testcases.c:362
#7 0x00000000004020b1 in main (argc=1, argv=0x7fffffffe0e8) at glXCreateWindow_testcases.c:371
I've made a patch to fix the issue https://patchwork.freedesktop.org/patch/242094/ .
__glXInitialize is being called before Mesa may know that context will be indirect thus dri display is created (this doesn't happen with LIBGL_ALWAYS_INDIRECT=1 due to the check in __glXInitialize). Later GetGLXDRIDrawable will be able to return non-null value which some places treat as indicator that dri is enabled. I added check if direct rendering is enabled before calling GetGLXDRIDrawable where necessary.