<div dir="ltr"><p class="MsoNormal">Hi,</p>

<p class="MsoNormal">I’ve reported a bug, long ago, regarding synchronous X
Library functions. (<a href="http://bugs.freedesktop.org/show_bug.cgi?id=17010">http://bugs.freedesktop.org/show_bug.cgi?id=17010</a>).</p>

<p class="MsoNormal">After investigating it a little further, it looks like a bug
in the extension code that was added to the X library to use XCB.</p>

<p class="MsoNormal">The _XReply function (xcb_io.c) maintains a replies list (dpy-&gt;xcb-&gt;pending_requests).
So when a new synchronous request is queued it is added to this list and the
function is waiting for a reply in xcb_wait_for_reply. When an error returns,
it is matched against the pending_requests and all is well.</p>

<p class="MsoNormal">That is until another thread calls an asynchronous function
(like XNextEvent). The wait_or_poll_for_event<span dir="RTL"></span><span dir="RTL" style="font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;mso-hansi-font-family:Calibri;mso-hansi-theme-font:
minor-latin;mso-bidi-font-family:Arial;mso-bidi-theme-font:minor-bidi"><span dir="RTL"></span> </span><span dir="LTR"></span><span dir="LTR"></span><span style="mso-spacerun:yes"> </span>function (xcb_io.c, called), called from
process_responses, is calling xcb_wait_for_event (xsb_in.c), this in turn reads
all events and errors. This function is part of XCB is not aware of the pending
request<span style="mso-spacerun:yes">  </span>list maintained by the X
library. When read_packet (xcb_in.c) is called it checks against the internal
list (c-&gt;in.pending_replies) and never finds any pending requests, thus the
error is being appended to the event queue, and an IO error is issued by
_XReply in the first thread.</p>

<p class="MsoNormal">This makes the XCB based X library unusable in multithreaded
GUI applications. <span class="Apple-style-span" style="font-family: Calibri; font-size: 15px; line-height: 17px; ">Some large customers
that want to utilize Fedora Core 8 or above or SLES11 find this very annoying.</span></p><p class="MsoNormal">There are two possible ways to solve this. One is to remove
pending_requests list from the X library and handle this list directly in XCB.
The other way is to check errors returned by XCB against this list.</p>

<p class="MsoNormal">Who is familiar with this code enough to explain which way
would not harm the current design of the Xlib/XCB integration?</p>

<p class="MsoNormal"><br></p><p class="MsoNormal">Thanks,</p>

<p class="MsoNormal">Yaakov Kaston</p><p class="MsoNormal"><br></p></div>