glXGetCurrentDisplay returning NULL even with appropriate visual

tom fogal tfogal at sci.utah.edu
Fri Nov 21 15:11:17 PST 2008


Hi, I've run into a snag in what seems like glX initialization.

Through debug versions of client libraries [1], I think I've
established why my application is segfaulting in XQueryExtension.  The
display (`dpy' variable) passed is NULL, which seems quite suspect.
Assuming that is indeed the problem, the root issue appears to be a:

    glXQueryVersion(glXGetCurrentDisplay(), ...);

line, where glXGetCurrentDisplay returns NULL.  Quite strangely, I
can call glXGetCurrentDisplay manually in the debugger, and it gives
me what seems to be a valid display; certainly not NULL.  My DISPLAY
seems set correctly; an XOpenDisplay call succeeds; glXChooseVisual
gives me a pointer instead of NULL.  I've thrown a `system("glxinfo");'
call in various places, and I get the appropriate output (direct
rendering is enabled, GL extensions are consistent, list of visuals
seems reasonable).

Since I'm using GLEW, I wonder if it is related to:

    http://www.nabble.com/using-chromium-and-glew--td15953506.html

As a summary, the user is trying to use Chromium with GLEW, and
dynamically loading glXGetCurrentDisplay via glXGetProcAddress appears
not to work when Chromium is thrown into the mix.  I'm not using
Chromium, however.

I have tried GLEW 1.3.4 and GLEW 1.5.1, which give little discernible
difference.  It seems like, in the 1.5.1 case, the Display I get back
from glXGetCurrentDisplay (when called manually in the debugger) has a
much larger set of values in the `event_vec' and `wire_vec' fields.

Attached is the relevant portions of a gdb session.  Any ideas what I
am (or my dependent libraries are...) doing wrong?

Thanks,

-tom

[1] Wow.  I haven't built X manually in quite some time, and it turned
    out to be wonderfully easy / work as expected to compile debug
    client libraries and then use LD_LIBRARY_PATH to debug my
    application.  Splitting to a modular build w/ autoconf was an
    excellent idea, great job.

-------------- next part --------------
Program received signal SIGSEGV, Segmentation fault.
0x00002b9cdb0f9074 in XQueryExtension (dpy=0x0, name=0x2b9cdaf78a2a "GLX", major_opcode=0x7fffda65d344, first_event=0x7fffda65d348, first_error=0x7fffda65d34c)
    at QuExt.c:46
46          LockDisplay(dpy);
Current language:  auto; currently c
(gdb) up
#1  0x00002b9cdb0e6f8b in XInitExtension (dpy=0x0, name=0x2b9cdaf78a2a "GLX") at InitExt.c:49
49              if (!XQueryExtension(dpy, name,
(gdb)
#2  0x00002b9cdd7deeb1 in XextAddDisplay (extinfo=0x8e0390, dpy=0x0, ext_name=0x2b9cdaf78a2a "GLX", hooks=0x2b9cdb088180, nevents=17, data=0x0) at extutil.c:112
112         dpyinfo->codes = XInitExtension (dpy, ext_name);
(gdb)
#3  0x00002b9cdaf3e45c in ?? () from /usr/lib64/libGL.so.1
(gdb)
#4  0x00002b9cdaf30b99 in glXQueryVersion () from /usr/lib64/libGL.so.1
(gdb)
#5  0x00002b9cd65476c8 in glxewContextInit () at glew/src/glew.c:6987
6987      glXQueryVersion(glXGetCurrentDisplay(), &major, &minor);
(gdb) p glXGetCurrentDisplay()
$1 = 9301840
(gdb) p (Display*) glXGetCurrentDisplay()
$2 = (struct _XDisplay *) 0x8def50
(gdb) p *(Display*) glXGetCurrentDisplay()
$3 = {ext_data = 0x8de7b0, free_funcs = 0x8e0260, fd = 17, conn_checker = 0, proto_major_version = 11, proto_minor_version = 0,
  vendor = 0x8dd8f0 "The X.Org Foundation", resource_base = 25165824, resource_mask = 2097151, resource_id = 0, resource_shift = 0,
  resource_alloc = 0x2b9cdb11328a <_XAllocID>, byte_order = 0, bitmap_unit = 32, bitmap_pad = 32, bitmap_bit_order = 0, nformats = 7, pixmap_format = 0x8e02b0,
  vnumber = 11, release = 70200000, head = 0xb12fc0, tail = 0x16e95270, qlen = 9, last_request_read = 81, request = 81, last_req = 0x2b9cdb3faba4 "",
  buffer = 0x8ef2b0 "\003\023\002", bufptr = 0x8ef2b0 "\003\023\002", bufmax = 0x9ef2b0 "", max_request_size = 65535, db = 0x0,
  synchandler = 0x2b9cdb107b6e <_XPrivSyncFunction>, display_name = 0x8dd9f0 ":0.0", default_screen = 0, nscreens = 1, screens = 0x8de620, motion_buffer = 256,
  flags = 8, min_keycode = 8, max_keycode = 255, keysyms = 0x0, modifiermap = 0x0, keysyms_per_keycode = 0,
  xdefaults = 0x8de980 "XTerm*background:\tblack\nXTerm*cursorBlink:\ttrue\nXTerm*cusorColor:\tyellow\nXTerm*font:\t10x20\nXTerm*foreground:\twhite\nXTerm*loginShell:\ttrue\nXTerm*scrollBar:\tfalse\n", scratch_buffer = 0x0, scratch_length = 0, ext_number = 4, ext_procs = 0x8deda0, event_vec = {0x2b9cdb10892a <_XUnknownWireEvent>,
    0x2b9cdb10892a <_XUnknownWireEvent>, 0x2b9cdb108940 <_XWireToEvent> <repeats 33 times>, 0x2b9cdd7dea7c <_xgeWireToEvent>,
    0x2b9cdb10892a <_XUnknownWireEvent> <repeats 79 times>, 0x2b9cdb183ab3 <wire_to_event>, 0x2b9cdb10892a <_XUnknownWireEvent> <repeats 12 times>}, wire_vec = {
    0x2b9cdb108935 <_XUnknownNativeEvent>, 0x2b9cdb108935 <_XUnknownNativeEvent>, 0 <repeats 33 times>, 0x2b9cdd7deb3a <_xgeEventToWire>,
    0x2b9cdb108935 <_XUnknownNativeEvent> <repeats 92 times>}, lock_meaning = 0, lock = 0x0, async_handlers = 0x0, bigreq_size = 4194303, lock_fns = 0x0,
  idlist_alloc = 0x2b9cdb113322 <_XAllocIDs>, key_bindings = 0x0, cursor_font = 0, atoms = 0x0, mode_switch = 0, num_lock = 0, context_db = 0x0, error_vec = 0x0,
  cms = {defaultCCCs = 0x0, clientCmaps = 0x8dec40 "\001", perVisualIntensityMaps = 0x0}, im_filters = 0x0, qfree = 0x0, next_event_serial_num = 10, flushes = 0x0,
  im_fd_info = 0x0, im_fd_length = 0, conn_watchers = 0x0, watcher_count = 0, filedes = 0x8e0230 "\021", savedsynchandler = 0x2b9cdb1024a4 <_XSyncFunction>,
  resource_max = 2097146, xcmisc_opcode = 0, xkb_info = 0x8de890, trans_conn = 0x0, xcb = 0x8de5b0}
(gdb) p glXGetCurrentDisplay
$4 = {<text variable, no debug info>} 0x2b9cdaf31030 <glXGetCurrentDisplay>
(gdb) bt
#0  0x00002b9cdb0f9074 in XQueryExtension (dpy=0x0, name=0x2b9cdaf78a2a "GLX", major_opcode=0x7fffda65d344, first_event=0x7fffda65d348, first_error=0x7fffda65d34c)
    at QuExt.c:46
#1  0x00002b9cdb0e6f8b in XInitExtension (dpy=0x0, name=0x2b9cdaf78a2a "GLX") at InitExt.c:49
#2  0x00002b9cdd7deeb1 in XextAddDisplay (extinfo=0x8e0390, dpy=0x0, ext_name=0x2b9cdaf78a2a "GLX", hooks=0x2b9cdb088180, nevents=17, data=0x0) at extutil.c:112
#3  0x00002b9cdaf3e45c in ?? () from /usr/lib64/libGL.so.1
#4  0x00002b9cdaf30b99 in glXQueryVersion () from /usr/lib64/libGL.so.1
#5  0x00002b9cd65476c8 in glxewContextInit () at glew/src/glew.c:6987
#6  0x00002b9cd6547e72 in glewInit () at glew/src/glew.c:7186
#7  0x00002aaab966518c in SLIVR::ShaderProgramARB::init_shaders_supported () from /local/dev/visit/src/lib/libslivrV.so
#8  0x00002aaab9422c0b in SLIVR::ShaderProgramARB::init_shaders_supported () at /local/dev/visit/src/include/slivr/ShaderProgramARB.h:71
#9  0x00002aaab941fdec in avtOpenGLSLIVRVolumeRenderer::Render (this=0x16f32c30, grid=0x1711afb0, data=0x170d7d70, opac=0x170d7d70, view=@0xed9528, atts=@0xed9600,
    vmin=0, vmax=1.01791625e-06, vsize=1.01791625e-06, omin=0, omax=5.15559691e-07, osize=5.15559691e-07, gx=0x17121b60, gy=0x1732fd10, gz=0x173ee5c0,
    gmn=0x1756b720, reducedDetail=false) at avtOpenGLSLIVRVolumeRenderer.C:388
#10 0x00002aaab940cf60 in avtVolumeRenderer::Render (this=0xed9520, ds=0x1711afb0) at avtVolumeRenderer.C:311
#11 0x00002b9cd3499459 in avtCustomRenderer::Execute (this=0xed9520, input=0x1711afb0) at avtCustomRenderer.C:212
#12 0x00002b9cd348656a in vtkUserDefinedMapperBridge::Render (this=0x16ed5060, r=0x8dd500) at avtUserDefinedMapper.C:491
#13 0x00002b9cd8fd4360 in vtkOpenGLActor::Render (this=0x16f76970, ren=0x8dd500, mapper=0x16ed5060) at /local/visitdeps/VTK/Rendering/vtkOpenGLActor.cxx:90
#14 0x00002b9cd8ed7705 in vtkActor::RenderOpaqueGeometry (this=0x16f76970, vp=0x8dd500) at /local/visitdeps/VTK/Rendering/vtkActor.cxx:175
#15 0x00002b9cd8f84847 in vtkRenderer::UpdateGeometry (this=0x8dd500) at /local/visitdeps/VTK/Rendering/vtkRenderer.cxx:489
#16 0x00002b9cd8ff4b8d in vtkOpenGLRenderer::DeviceRender (this=0x8dd500) at /local/visitdeps/VTK/Rendering/vtkOpenGLRenderer.cxx:170
#17 0x00002b9cd8f854b9 in vtkRenderer::Render (this=0x8dd500) at /local/visitdeps/VTK/Rendering/vtkRenderer.cxx:254
#18 0x00002b9cd8f8b32c in vtkRendererCollection::Render (this=0x8de510) at /local/visitdeps/VTK/Rendering/vtkRendererCollection.cxx:52
#19 0x00002b9cd8f76359 in vtkRenderWindow::DoStereoRender (this=0x8de320) at /local/visitdeps/VTK/Rendering/vtkRenderWindow.cxx:627
#20 0x00002b9cd8f768ba in vtkRenderWindow::DoFDRender (this=0x8de320) at /local/visitdeps/VTK/Rendering/vtkRenderWindow.cxx:615
#21 0x00002b9cd8f77076 in vtkRenderWindow::DoAARender (this=0x8de320) at /local/visitdeps/VTK/Rendering/vtkRenderWindow.cxx:508
#22 0x00002b9cd8f77852 in vtkRenderWindow::Render (this=0x8de320) at /local/visitdeps/VTK/Rendering/vtkRenderWindow.cxx:334
#23 0x00002b9cd900ce9e in vtkXOpenGLRenderWindow::Render (this=0x8de320) at /local/visitdeps/VTK/Rendering/vtkXOpenGLRenderWindow.cxx:1377
#24 0x00002b9cd31349bd in VisWinRendering::ScreenRender (this=0x8dd380, doViewportOnly=true, doCanvasZBufferToo=true, doOpaque=true, doTranslucent=true,
    input=@0x7fffda65e370) at Colleagues/VisWinRendering.C:1029
#25 0x00002b9cd318e070 in VisWindow::ScreenCapture (this=0x8e6d30, doViewportOnly=true, doZBufferToo=true, doOpaque=true, doTranslucent=true, input=@0x7fffda65e440)
    at VisWindow/VisWindow.C:1866
#26 0x00002b9cd0738c92 in NetworkManager::RenderGeometry (this=0x8dab00) at NetworkManager.C:5428
#27 0x00002b9cd07493a2 in NetworkManager::Render (this=0x8dab00, plotIds=@0x7fffda65e740, getZBuffer=false, annotMode=2, windowID=0, leftEye=true)
    at NetworkManager.C:2202
#28 0x00002b9cd070b773 in RPCExecutor<RenderRPC>::Execute (this=0xc36b60, rpc=0xc1bee0) at ./Executors.h:1413
#29 0x00002b9cd071dd6c in RPCExecutor<RenderRPC>::Update (this=0xc36b60, s=0xc1bf28) at ../../include/visit/RPCExecutor.h:67
#30 0x00002b9cd22b8cb8 in Subject::Notify (this=0xc1bf28) at Subject.C:188
#31 0x00002b9cd2191111 in AttributeSubject::Notify (this=0xc1bee0) at AttributeSubject.C:99
#32 0x00002b9cd60cd7aa in MPIXfer::Process (this=0x6c1670) at MPIXfer.C:316
#33 0x00002b9cd0703bcd in Engine::ProcessInput (this=0x6c0d10) at Engine.C:1189
#34 0x00002b9cd0706172 in Engine::EventLoop (this=0x6c0d10) at Engine.C:1135
#35 0x00002b9cd070636c in Engine::PAR_EventLoop (this=0x6c0d10) at Engine.C:956
#36 0x000000000040b017 in main (argc=10, argv=0x7fffda65ef98) at main.C:315


More information about the xorg mailing list