Skip to content
  • Keith Packard's avatar
    Avoid recursing through _XError due to sequence adjustment · 30ccef3a
    Keith Packard authored
    This patch is based on research done by Dmitry Osipenko to uncover the
    cause of a large class of Xlib lockups.
    
    _XError must unlock and re-lock the display around the call to the
    user error handler function. When re-locking the display, two
    functions are called to ensure that the display is ready to generate a request:
    
        _XIDHandler(dpy);
        _XSeqSyncFunction(dpy);
    
    The first ensures that there is at least one XID available to use
    (possibly calling _xcb_generate_id to do so). The second makes sure a
    reply is received at least every 65535 requests to keep sequence
    numbers in sync (possibly generating a GetInputFocus request and
    synchronously awaiting the reply).
    
    If the second of these does generate a GetInputFocus request and wait
    for the reply, then a pending error will cause recursion into _XError,
    which deadlocks the display.
    
    One seemingly easy fix is to have _XError avoid those calls by
    invoking InternalLockDisplay instead of LockDisplay....
    30ccef3a