[Xcb] Troubleshooting xcb/X11 deadlocks

Uli Schlachter psychon at znc.in
Mon Dec 7 11:35:20 PST 2015


Hi,

Am 07.12.2015 um 17:16 schrieb Bill Soudan:
[...]
> Deadlock example 1:
> 
> (gdb) where
> #0  0x00007ffff7bcb91f in pthread_cond_wait@@GLIBC_2.3.2 () from
> /nix/store/npfsi1d9ka8zwnxzn3sr08hbwvpapyk7-glibc-2.21/lib/libpthread.so.0
> #1  0x00007ffff702f85d in _XReply () from
> /nix/store/nz63mdn3nsridd4fbxjrzf49rpv0mbsp-libX11-1.6.3/lib/libX11.so.6
> #2  0x00007ffff702b3ed in XSync () from
> /nix/store/nz63mdn3nsridd4fbxjrzf49rpv0mbsp-libX11-1.6.3/lib/libX11.so.6
> #3  0x0000000000506708 in XWindowsUtil::ErrorLock::install
> (this=0x7fffffffbad0,
>     handler=0x5067be <XWindowsUtil::ErrorLock::ignoreHandler(_XDisplay*,
> XErrorEvent*, void*)>, data=0x0)
>     at /home/bsoudan/src/synergy/src/lib/platform/XWindowsUtil.cpp:1754

I don't have line numbers, but I guess that this is the following code:

	xcb_generic_reply_t *event;
	/* If some thread is already waiting for events,
	 * it will get the first one. That thread must
	 * process that event before we can continue. */
	/* FIXME: That event might be after this reply,
	 * and might never even come--or there might be
	 * multiple threads trying to get events. */
	while(dpy->xcb->event_waiter)
	{ /* need braces around ConditionWait */
		ConditionWait(dpy, dpy->xcb->event_notify);
	}
	while((event = poll_for_event(dpy)))
		handle_response(dpy, event, True);

[...]
> (gdb) where
> #0  0x00007ffff5cd94bd in poll () from
> /nix/store/npfsi1d9ka8zwnxzn3sr08hbwvpapyk7-glibc-2.21/lib/libc.so.6
> #1  0x00007ffff4d45202 in _xcb_conn_wait () from
> /nix/store/8lin073px65ziw1knd47183pgqy55h2s-libxcb-1.11/lib/libxcb.so.1
> #2  0x00007ffff4d46c9f in xcb_wait_for_event () from
> /nix/store/8lin073px65ziw1knd47183pgqy55h2s-libxcb-1.11/lib/libxcb.so.1
> #3  0x00007ffff702f4a8 in _XReadEvents () from
> /nix/store/nz63mdn3nsridd4fbxjrzf49rpv0mbsp-libX11-1.6.3/lib/libX11.so.6
> #4  0x00007ffff7017bf9 in XIfEvent () from
> /nix/store/nz63mdn3nsridd4fbxjrzf49rpv0mbsp-libX11-1.6.3/lib/libX11.so.6
> #5  0x0000000000505cc8 in XWindowsUtil::getCurrentTime (display=0x7ac480,
> window=2097156) at
> /home/bsoudan/src/synergy/src/lib/platform/XWindowsUtil.cpp:1455

This thread is in _XReadEvents() and, well, waits for any event to arrive. This
seems to be the only thread that is actually in an XCB function. No idea why no
event arrives. The code sounds like it did something so that a PropertyNotify
event should come in...?

However, I can explain why this blocks the first thread. This is waiting for an
event and thus the first thread doesn't start waiting for an event, too, and
instead waits for this thread to be done. See the FIXME above.

The bug is in libX11, so better ask them about it.

[...]
> 
> Deadlock example 2:
> 
> Program received signal SIGUSR1, User defined signal 1.
> 0x00007ffff7bcb91f in pthread_cond_wait@@GLIBC_2.3.2 () from
> /nix/store/npfsi1d9ka8zwnxzn3sr08hbwvpapyk7-glibc-2.21/lib/libpthread.so.0
> (gdb) where
> #0  0x00007ffff7bcb91f in pthread_cond_wait@@GLIBC_2.3.2 () from
> /nix/store/npfsi1d9ka8zwnxzn3sr08hbwvpapyk7-glibc-2.21/lib/libpthread.so.0
> #1  0x00007ffff702f85d in _XReply () from
> /nix/store/nz63mdn3nsridd4fbxjrzf49rpv0mbsp-libX11-1.6.3/lib/libX11.so.6
> #2  0x00007ffff7016876 in XGetWindowProperty () from
> /nix/store/nz63mdn3nsridd4fbxjrzf49rpv0mbsp-libX11-1.6.3/lib/libX11.so.6
> #3  0x0000000000505850 in XWindowsUtil::getWindowProperty
> (display=0x7ac480, window=2097156, property=295, data=0x0,
> type=0x7fffffffbb88, format=0x0,
>     deleteProperty=false) at
> /home/bsoudan/src/synergy/src/lib/platform/XWindowsUtil.cpp:1320

That looks the same as in the first example.

[...]
> (gdb) thread 18
> [Switching to thread 18 (Thread 0x7fffe37fe700 (LWP 7916))]
> #0  0x00007ffff5cd94bd in poll () from
> /nix/store/npfsi1d9ka8zwnxzn3sr08hbwvpapyk7-glibc-2.21/lib/libc.so.6
> (gdb) where
> #0  0x00007ffff5cd94bd in poll () from
> /nix/store/npfsi1d9ka8zwnxzn3sr08hbwvpapyk7-glibc-2.21/lib/libc.so.6
> #1  0x00007ffff4d45202 in _xcb_conn_wait () from
> /nix/store/8lin073px65ziw1knd47183pgqy55h2s-libxcb-1.11/lib/libxcb.so.1
> #2  0x00007ffff4d46c9f in xcb_wait_for_event () from
> /nix/store/8lin073px65ziw1knd47183pgqy55h2s-libxcb-1.11/lib/libxcb.so.1
> #3  0x00007ffff702f4a8 in _XReadEvents () from
> /nix/store/nz63mdn3nsridd4fbxjrzf49rpv0mbsp-libX11-1.6.3/lib/libX11.so.6
> #4  0x00007ffff7017bf9 in XIfEvent () from
> /nix/store/nz63mdn3nsridd4fbxjrzf49rpv0mbsp-libX11-1.6.3/lib/libX11.so.6
> #5  0x0000000000505cc8 in XWindowsUtil::getCurrentTime (display=0x7ac480,
> window=2097156) at
> /home/bsoudan/src/synergy/src/lib/platform/XWindowsUtil.cpp:1455
[...]

Oh, hey, didn't we have this function also in the example #1? :-)

So, as far as I can see, both of these are bugs in libX11 and not in libxcb. Sorry.

Uli
-- 
“Some people are worth melting for.” - Olaf


More information about the Xcb mailing list