Skip to content
  • Dmitry Osipenko's avatar
    Fix lockup in _XReply() caused by recursive synchronization · f5ba2c63
    Dmitry Osipenko authored and Adam Jackson's avatar Adam Jackson committed
    This patch is based on a suggestion made by Uli Schlachter in a comment
    to the bug report #93.
    
    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
    
    
    Suggested-by: default avatarUli Schlachter <psychon@znc.in>
    Tested-by: default avatarDmitry Osipenko <digetx@gmail.com>
    Reported-by: default avatarDmitry Osipenko <digetx@gmail.com>
    Signed-off-by: default avatarDmitry Osipenko <digetx@gmail.com>
    f5ba2c63