Bug 29875

Summary: Hangs and "Assertion `c->out.request == c->out.request_written' failed" in xcb when using OpenGL
Product: XCB Reporter: Philip Taylor <excors>
Component: LibraryAssignee: xcb mailing list dummy <xcb>
Status: RESOLVED FIXED QA Contact: xcb mailing list dummy <xcb>
Severity: normal    
Priority: medium Keywords: patch
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Keep flushing when transfering socket to Xlib

Description Philip Taylor 2010-08-29 11:51:51 UTC
I'm running the map editor tool from http://trac.wildfiregames.com/wiki/LatestRelease ("./pyrogenesis_dbg -editor") (sorry, not a very minimal test case). It does roughly the following:

Thread 1: call XInitThreads(); create thread 2.
Thread 2: create wxWidgets (Gtk+) window; create GL context (glXCreateNewContext); pass GL context to thread 1; run wxWidgets event loop.
Thread 1: adopt GL context (glXMakeContextCurrent using the display/window/context from thread 2); run rendering loop.

Thread 1 very quickly hangs inside xcb_wait_for_reply during various GL/GLX calls (xcb_glx_gen_textures_reply, Mesa's __indirect_glGetError, etc). Interacting with thread 2 (e.g. waving the mouse over the window) temporarily unblocks thread 1 and it usually continues correctly for a fraction of a second.

If I run with the normal Intel GL drivers, it typically carries on like this for seconds or minutes, and then hangs permanently.

If I run with LIBGL_ALWAYS_INDIRECT=1 then I get an assertion failure in thread 2 before the first frame is rendered:

  pyrogenesis_dbg: xcb_out.c:272: xcb_take_socket: Assertion `c->out.request == c->out.request_written' failed.

  (gdb) print c->out.request
  $1 = 5459
  (gdb) print c->out.request_written
  $2 = 5456

Currently running on Gentoo with libxcb 1.7, libX11 1.3.5, mesa 7.8.2. This used to work fine for me (from some years ago until some months ago - unfortunately I didn't track what libraries I'd updated when it broke). I don't know whether anyone else has experienced this problem.

I'm happy to provide more information needed to help debug this, but I'm not sure where the problem is or what's needed.
Comment 1 Keith Packard 2011-12-01 02:58:03 UTC
Created attachment 53997 [details] [review]
Keep flushing when transfering socket to Xlib

The assertion failure happens when some other thread manages to sneak in additional requests while transferring the socket back to Xlib.
Comment 2 Julien Danjou 2012-01-11 08:49:21 UTC
Patch merged.

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.