[Xcb] Xlib/XCB in multi-threaded situation results in deadlock

Rami Ylimäki rami.ylimaki at vincit.fi
Wed Dec 1 14:13:17 PST 2010


2010/12/1 Josh Triplett <josh at joshtriplett.org>

> > It seems that the drawing thread is suck on the poll and waiting for a
> > reply, while the input thread is actually reading data from the socket.
> > This causes the above deadlock.
>
> Strange.  Obviously this *shouldn't* happen. :)
>
> > The below patch quickly fabricated here makes the window of opportunity
> > for the situation to arise sufficiently small (its not a proper fix!).
>
> Interesting; while not a proper fix, as you said, your patch does help
> point at potential culprits.  Thanks!
>

Jamey was involved with this same problem a while ago. I provided patches
but those weren't accepted, because the patches required such interface
changes in libxcb that could have encouraged potentially dangerous use of
the library.

The original patches can be found here:
http://lists.freedesktop.org/archives/xcb/2010-October/006491.html. Some
discussion followed and the patches weren't accepted.

Jamey told that he's trying to think of a fix using poll() in libX11 that
wouldn't require interface changes in libxcb. Before proceeding he asked me
to supply a fixed version of one patch from the previous series. I did that
in http://lists.freedesktop.org/archives/xcb/2010-October/006516.html but it
seems that the patch was forgotten, or Jamey has agreed with Josh not to
apply it.


> > Does anyone have a good idea of the causes of this problem and the
> > effects it has? I think some in-depth analysis would be in order to
> > solve the problem.
>

It seems that libX11 has suffered from this since
http://cgit.freedesktop.org/xorg/lib/libX11/commit/?id=933aee1d5c53b0cc7d608011a29188b594c8d70b.
All you have to do is wait for an event in one thread and wait for a reply
in another one to trigger it. The reply waiter cannot continue until an
event arrives. The _XReply and _XReadEvents functions of libX11 need to be
fixed to solve this.

It's possible to fix this with interface changes in libxcb. It's probably
possible to fix it without interface changes also, but that may be harder.


>
> Just to confirm, can you provide the exact versions of XCB and of
> Xlib that you have?  Xlib 1.4 had some potentially relevant fixes.
>

I don't think that this has been fixed in libX11 yet.


> - Josh Triplett
>

-- Rami
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20101202/8331e088/attachment.html>


More information about the Xcb mailing list