[Development] [OS X/xcb] error: xp_attach_gl_context returned: 2 followed by hang during application exit

René J.V. Bertin rjvbertin at gmail.com
Sun Mar 29 16:29:38 CEST 2015


Hello,

I know there is no official support for using the xcb platform plugin on OS X, but since it builds (without particular hurdles):

The OpenGL examples run on a local X server, despite the fact that the xcb plugin links to both the X11 GL libraries and {OpenGL,AGL}.framework . However, quitting apparently requires closing the window through the window manager, and when I do that I get an error on the calling terminal

error: xp_attach_gl_context returned: 2

the error is apparently printed by apple_glx_make_current_context:

Process 84025 stopped
* thread #1: tid = 0x1cf5578, 0x0000000105743b3a libXplugin.1.dylib`xp_attach_gl_context, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000105743b3a libXplugin.1.dylib`xp_attach_gl_context
libXplugin.1.dylib`xp_attach_gl_context:
-> 0x105743b3a:  pushq  %rbp
   0x105743b3b:  movq   %rsp, %rbp
   0x105743b3e:  pushq  %r14
   0x105743b40:  pushq  %rbx
(lldb) finish
Process 84025 stopped
* thread #1: tid = 0x1cf5578, 0x00000001053f46c4 libGL.1.dylib`surface_make_current + 93, queue = 'com.apple.main-thread', stop reason = step out
    frame #0: 0x00000001053f46c4 libGL.1.dylib`surface_make_current + 93
libGL.1.dylib`surface_make_current + 93:
-> 0x1053f46c4:  movl   %eax, %ecx
   0x1053f46c6:  testl  %ecx, %ecx
   0x1053f46c8:  je     0x1053f46eb               ; surface_make_current + 132
   0x1053f46ca:  movq   0x43957(%rip), %rax       ; (void *)0x00007fff769367d8: __stderrp
(lldb) finish
error: xp_attach_gl_context returned: 2
Process 84025 stopped
* thread #1: tid = 0x1cf5578, 0x00000001053f2c0b libGL.1.dylib`apple_glx_make_current_context + 706, queue = 'com.apple.main-thread', stop reason = step out
    frame #0: 0x00000001053f2c0b libGL.1.dylib`apple_glx_make_current_context + 706
libGL.1.dylib`apple_glx_make_current_context + 706:
-> 0x1053f2c0b:  movb   $0x1, %r14b
   0x1053f2c0e:  testb  %al, %al
   0x1053f2c10:  jne    0x1053f2bac               ; apple_glx_make_current_context + 611
   0x1053f2c12:  jmp    0x1053f2a7a               ; apple_glx_make_current_context + 305
(lldb) bt
* thread #1: tid = 0x1cf5578, 0x00000001053f2c0b libGL.1.dylib`apple_glx_make_current_context + 706, queue = 'com.apple.main-thread', stop reason = step out
  * frame #0: 0x00000001053f2c0b libGL.1.dylib`apple_glx_make_current_context + 706
    frame #1: 0x00000001053fbbe4 libGL.1.dylib`applegl_bind_context + 61
    frame #2: 0x00000001053f8a53 libGL.1.dylib`MakeContextCurrent + 289
    frame #3: 0x00000001052be087 libqxcb.dylib`QGLXContext::makeCurrent(this=0x0000000103531750, surface=0x000000010352fb30) + 103 at qglxintegration.cpp:476
    frame #4: 0x000000010093129e QtGui`QOpenGLContext::makeCurrent(this=0x0000000103530240, surface=0x000000010352f5a0) + 174 at qopenglcontext.cpp:896
    frame #5: 0x00000001000901a1 QtWidgets`QWidgetPrivate::deleteTLSysExtra(this=0x000000010360dbd0) + 81 at qwidget.cpp:1814
    frame #6: 0x000000010008ff5e QtWidgets`QWidget::destroy(this=<unavailable>, destroyWindow=<unavailable>, destroySubWindows=<unavailable>) + 1022 at qwidget.cpp:12202
    frame #7: 0x000000010008f617 QtWidgets`QWidget::~QWidget(this=0x00007fff5fbfee20) + 1639 at qwidget.cpp:1647
    frame #8: 0x0000000100003fd7 textures`main + 119
    frame #9: 0x00007fff9158f5fd libdyld.dylib`start + 1

When I let the application continue, it will eventually hang:
(lldb) c
Process 84025 resuming
Process 84025 stopped
* thread #1: tid = 0x1cf5578, 0x00007fff869d4746 libsystem_kernel.dylib`__psynch_mutexwait + 10, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    frame #0: 0x00007fff869d4746 libsystem_kernel.dylib`__psynch_mutexwait + 10
libsystem_kernel.dylib`__psynch_mutexwait + 10:
-> 0x7fff869d4746:  jae    0x7fff869d4750            ; __psynch_mutexwait + 20
   0x7fff869d4748:  movq   %rax, %rdi
   0x7fff869d474b:  jmp    0x7fff869d1175            ; cerror_nocancel
   0x7fff869d4750:  retq   
(lldb) c
Process 84025 resuming
Process 84025 stopped
* thread #1: tid = 0x1cf5578, 0x00007fff869d4746 libsystem_kernel.dylib`__psynch_mutexwait + 10, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    frame #0: 0x00007fff869d4746 libsystem_kernel.dylib`__psynch_mutexwait + 10
libsystem_kernel.dylib`__psynch_mutexwait + 10:
-> 0x7fff869d4746:  jae    0x7fff869d4750            ; __psynch_mutexwait + 20
   0x7fff869d4748:  movq   %rax, %rdi
   0x7fff869d474b:  jmp    0x7fff869d1175            ; cerror_nocancel
   0x7fff869d4750:  retq   
(lldb) bt
* thread #1: tid = 0x1cf5578, 0x00007fff869d4746 libsystem_kernel.dylib`__psynch_mutexwait + 10, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x00007fff869d4746 libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x00007fff87c53779 libsystem_pthread.dylib`_pthread_mutex_lock + 372
    frame #2: 0x0000000107e84e74 libX11.6.dylib`_XLockDisplay + 24
    frame #3: 0x00000001053f73cd libGL.1.dylib`glXDestroyContext + 87
    frame #4: 0x00000001052bdf46 libqxcb.dylib`QGLXContext::~QGLXContext() [inlined] QGLXContext::~QGLXContext(this=0x0000000103531750) + 29 at qglxintegration.cpp:446
    frame #5: 0x00000001052bdf29 libqxcb.dylib`QGLXContext::~QGLXContext() [inlined] QGLXContext::~QGLXContext(this=0x0000000103531750) at qglxintegration.cpp:444
    frame #6: 0x00000001052bdf29 libqxcb.dylib`QGLXContext::~QGLXContext(this=0x0000000103531750) + 9 at qglxintegration.cpp:444
    frame #7: 0x0000000100930546 QtGui`QOpenGLContext::destroy(this=<unavailable>) + 310 at qopenglcontext.cpp:634
    frame #8: 0x0000000100930b8c QtGui`QOpenGLContext::~QOpenGLContext() [inlined] QOpenGLContext::~QOpenGLContext(this=0x0000000103530240) + 19 at qopenglcontext.cpp:666
    frame #9: 0x0000000100930b79 QtGui`QOpenGLContext::~QOpenGLContext() [inlined] QOpenGLContext::~QOpenGLContext(this=0x0000000103530240) at qopenglcontext.cpp:665
    frame #10: 0x0000000100930b79 QtGui`QOpenGLContext::~QOpenGLContext(this=0x0000000103530240) + 9 at qopenglcontext.cpp:665
    frame #11: 0x0000000100090266 QtWidgets`QWidgetPrivate::deleteTLSysExtra(this=0x000000010360dbd0) + 278 at qwidget.cpp:1822
    frame #12: 0x000000010008ff5e QtWidgets`QWidget::destroy(this=<unavailable>, destroyWindow=<unavailable>, destroySubWindows=<unavailable>) + 1022 at qwidget.cpp:12202
    frame #13: 0x000000010008f617 QtWidgets`QWidget::~QWidget(this=0x00007fff5fbfee20) + 1639 at qwidget.cpp:1647
    frame #14: 0x0000000100003fd7 textures`main + 119
    frame #15: 0x00007fff9158f5fd libdyld.dylib`start + 1

It'd be easy to chalk this off to a bug in libX11 and/or Mesa, but maybe the Qt code isn't without blame either? Where could I look for relevant code paths that are not identical on OS X and Unix/X11/xcb ?
FWIW, the "host" Qt install is built normally for OS X; the xcb plugin is created by building qtbase once more with the relevant options set (and only the xcb platform and platforminput plugins are then installed to the Qt plugins directory). The examples are built normally.


Thanks,
R.



More information about the Development mailing list