Skip to content

Fix lockup in _XReply() caused by recursive synchronization

Dmitry Osipenko requested to merge digetx/libx11:lockup-fix into master

This patch is based on a suggestion made by Uli Schlachter @psychon in a comment to the bug report #93 (closed).

Explanation of the bug (given by Uli Schlachter as well):

An error was received and handled. Since there was an error callback set, Xlib unlocks the display, runs the error callback, and then locks the display again. This goes through _XLockDisplay and then calls _XSeqSyncFunction. On this "lock the thing"-path, Xlib notices that sequence numbers are close to wrap-around and tries to send a GetInputFocus request. However, the earlier calls already registered themselves as "we are handling replies/errors, do not interfere!" and so the code here waits for "that other thread" to be done before it continues. Only that there is no other thread, but it is this thread itself and thus a deadlock follows.

The bug is relatively easy to reproduce on any desktop environment by using actively a touchscreen input that supports multitouch, i.e. practically all mobile devices are affected.

Fixes: #93 (closed)

Suggested-by: Uli Schlachter
Tested-by: Dmitry Osipenko
Reported-by: Dmitry Osipenko
Signed-off-by: Dmitry Osipenko

Merge request reports