This problem was first noticed at the beginning of year 2009 with XNEE. It seems that the problem has been worked around in XNEE but not fixed properly in Xlib. One source of confusion last year seems to be the problems with recording extension and therefore the problem probably wasn't linked to Xlib. You can reproduce this with older version of XNEE or with the attached test case. Last time I checked, Xlib 1.1.5 didn't have this problem. Newer versions do and if I remember correctly --with-xcb is required even though I haven't checked that recently. What you need to do is: ctrl_disp = XOpenDisplay(NULL); data_disp = XOpenDisplay(NULL); XSynchronize(ctrl_disp, True); XRecordQueryVersion(ctrl_disp, &major, &minor); rc = XRecordCreateContext (ctrl_disp, 0, &rcs, 1, &rr, 1); XRecordEnableContextAsync(data_disp, rc, event_callback, NULL); XFlush(data_disp); The request to enable context will fail because it hasn't been created yet. In other words the request to create context hasn't been flushed to X server even though the display connection has been set as synchronous. It seems that xcb_io.c:_XAllocID overrides the sync function with a private version. XRecordCreateContext calls XAllocID, which causes the SyncHandle at the end of the request to do nothing.
Created attachment 34905 [details] test case Adding xcb@lists.freedesktop.org into CC.
Thanks for the test case! It made the bug pretty easy to track down. I've pushed a fix to libX11 git. It looks like this has indeed been broken in every XCB-enabled release of libX11 ever. Oops. ...I blame keithp. ;-) After applying the fix, I found that the test program hangs in XCloseDisplay on the data_disp connection, waiting for the server to respond to an XSync. I had to insert "XRecordDisableContext (ctrl_disp, rc);" before that to get it to exit successfully. Is that expected? I'm not sure how Record is supposed to work.
(In reply to comment #2) > Thanks for the test case! It made the bug pretty easy to track down. I've > pushed a fix to libX11 git. It looks like this has indeed been broken in every > XCB-enabled release of libX11 ever. Oops. ...I blame keithp. ;-) > > After applying the fix, I found that the test program hangs in XCloseDisplay on > the data_disp connection, waiting for the server to respond to an XSync. I had > to insert "XRecordDisableContext (ctrl_disp, rc);" before that to get it to > exit successfully. Is that expected? I'm not sure how Record is supposed to > work. Thanks for fixing it so quickly. You are right, the test case had a bug and XRecordDisableContext call should be there. The original test case had that call but I removed it when trying to minimize it. It's also possible to make the test case work without XRecordDisableContext by executing XCloseDisplay (ctrl_disp); XCloseDisplay (data_disp); instead of XCloseDisplay (data_disp); XCloseDisplay (ctrl_disp); at the end of the case.
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.