Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-88435

QXcbConnection::getTimestamp runs in indefinite loop when X server shuts down

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 5.15.1
    • Fix Version/s: 5.12.11, 6.1.0
    • Component/s: QPA: X11/XCB
    • Labels:
    • Platform/s:
      Linux/X11
    • Commits:
      dbd1c8b047700bb6d0adae848d6cbb89fa2fcfff (qt/qtbase/dev) fb61cd8df838eb7aa91adf9cc87d2ad2409e9c88 (qt/qtbase/5.12) 5519447b9db4023deca98e5b882845416a9c33f1 (qt/qtbase/5.15)

      Description

      This bug was found in KDE's kwin_x11. Bug 415008 - KWin-5.17.4 hangs inside loop in QXcbConnection::getTimestamp. The basic call stack looks like:

       

       #2 0x00007fc46bb1dcc8 in QXcbConnection::getTimestamp() () at /lib64/libQt5XcbQpa.so.5
       #3 0x00007fc46bb38e52 in QXcbNativeInterface::getTimestamp(QXcbScreen const*) () at /lib64/libQt5XcbQpa.so.5
       #4 0x00007fc46bb39cb3 in QXcbNativeInterface::nativeResourceForScreen(QByteArray const&, QScreen*) () at /lib64/libQt5XcbQpa.so.5
       #5 0x00007fc47fd2ac56 in QX11Info::getTimestamp() () at /lib64/libQt5X11Extras.so.5
       #6 0x00007fc480100d18 in KWin::Platform::updateXTime() () at /lib64/libkwin.so.5
      

      Kwin is running QX11Info::getTimestamp(), which is a blocking call and cannot throw exception. But X server disconnects (Xrdp terminates Xvnc). But the code block looks like:

      xcb_timestamp_t QXcbConnection::getTimestamp()
      {
      ...
          xcb_generic_event_t *event = nullptr;
          while (!event) {
              connection()->sync();
              event = eventQueue()->peek([window, dummyAtom](xcb_generic_event_t *event, int type) {
                  if (type != XCB_PROPERTY_NOTIFY)
                      return false;
                  auto propertyNotify = reinterpret_cast<xcb_property_notify_event_t *>(event);
                  return propertyNotify->window == window && propertyNotify->atom == dummyAtom;
              });
          }
      

      QXcbConnection::getTimestamp() cannot step out of the while loop.

      According to Qt's design, I cannot throw exception here.

      So my proposal is use CurrentTime from X11 to mark an invalid timestamp. Because X11 server will never generates CurrenTime.

        Attachments

        For Gerrit Dashboard: QTBUG-88435
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            ivzhh Sheng Mao
            Reporter:
            ivzhh Sheng Mao
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews