[Xcb] [PATCH 2/3] fix deadlock with xcb_take_socket/return_socket v3
Uli Schlachter
psychon at znc.in
Fri May 24 07:54:00 PDT 2013
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
On 15.05.2013 11:21, Christian König wrote:
> From: Christian König <christian.koenig at amd.com>
>
> To prevent different threads from stealing the socket from each other the
> caller of "xcb_take_socket" must hold a lock that is also acquired in
> "return_socket". Unfortunately xcb tries to prevent calling return_socket
> from multiple threads and this can lead to a deadlock situation.
>
> A simple example: - X11 has taken the socket - Thread A has locked the
> display. - Thread B does xcb_no_operation() and thus ends up in libX11's
> return_socket(), waiting for the display lock. - Thread A calls e.g.
> xcb_no_operation(), too, ends up in return_socket() and because
> socket_moving == 1, ends up waiting for thread B => Deadlock
>
> This patch allows calling return_socket from different threads at the same
> time an so resolves the deadlock situation.
>
> Partially fixes: https://bugs.freedesktop.org/show_bug.cgi?id=20708
>
> v2: fixes additional pthread_cond_wait dependencies, rework comments and
> patch description
>
> v3: separate pthread_cond_wait dependencies and unrelated whitespace change
> into their own patch, use unsigned for socket_seq
>
> Signed-off-by: Christian König <christian.koenig at amd.com>
After staring at this patch for a while and thinking about weird thread
issues, I come to the conclusion that:
Reviewed-by: Uli Schlachter <psychon at znc.in>
What do others think? If no one objects, this patch could be pushed to master.
Cheers,
Uli
P.S.: I'll stare at patch 3/3 for a little more and try to come up with a
small test program for it. Hopefully that convinces me about it, too.
- --
"Why make things difficult, when it is possible to make them cryptic
and totally illogical, with just a little bit more effort?" -- A. P. J.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iQEcBAEBCAAGBQJRn38EAAoJECLkKOvLj8sGO0IIAJLZYFGk9btsK36oW5VVp0nL
QnOIApxr5QU4VJnBE/IgBGhxtjYoxfssLyhJwBcFZUkpKpv17NmFUxEB2QtGiomw
DR3DHPALKiNc64XJUBDtND7uMmr/IotJMXK7shiFz9US7PsAvP6fWpnC9q/eLTvi
ThFpLfcwlxoWtXTTFxBy3hbWUqrkxW7d3gyR7+OAPl35LPQhhg+NPPUEHTt+GGwL
bd6yIYRZIKHOw3uBCWx5IomYAYg32zz8epGe8ol/itEMvu857AgOhfdbryGogUFH
H2TcNitNdHLsBa8ZIii5NIhJLz6/y4bHHeaYQMMvIkd7WjSulzRq2o3gD+UWp1A=
=HT9k
-----END PGP SIGNATURE-----
More information about the Xcb
mailing list