Bug 415008 - KWin-5.17.4 hangs inside loop in QXcbConnection::getTimestamp()
Summary: KWin-5.17.4 hangs inside loop in QXcbConnection::getTimestamp()
Status: RESOLVED NOT A BUG
Alias: None
Product: kwin
Classification: Plasma
Component: platform-x11-standalone (show other bugs)
Version: 5.17.4
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-10 09:24 UTC by Jaak Ristioja
Modified: 2022-05-17 19:19 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
jaak: X11+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jaak Ristioja 2019-12-10 09:24:07 UTC
SYMPTOMS

KWin hangs randomly, consuming 100% CPU.

SOFTWARE/OS VERSIONS

Linux/KDE Plasma: Gentoo Linux, kde-plasma/kwin-5.17.4
KDE Plasma Version: 5.17.4
KDE Frameworks Version: 5.64.0
Qt Version: 5.13.2
libxcb: x11-libs/libxcb-1.13.1
X11: x11-base/xorg-server-1.20.5


ADDITIONAL INFORMATION

I've only recently started seeing this issue (3-4 times in the last 6 days), I suspect this to be a regression introduced in <something>-5.17.4.

Thread 1 (Thread 0x7f22ee85ce00 (LWP 203769)):
#0  0x00007f22edfecd94 in QXcbEventQueue::peek<QXcbConnection::getTimestamp()::<lambda(xcb_generic_event_t*, int)> > [inline] (option=QXcbEventQueue::PeekRemoveMatch, peeker=..., this=0x55cab6a65ab0) at qxcbconnection.cpp:783
#1  0x00007f22edfecd94 in QXcbEventQueue::peek<QXcbConnection::getTimestamp()::<lambda(xcb_generic_event_t*, int)> > [inline] (peeker=..., this=0x55cab6a65ab0) at qxcbeventqueue.h:97
#2  0x00007f22edfecd94 in QXcbConnection::getTimestamp() (this=0x55cab6a56390) at qxcbconnection.cpp:782
#3  0x00007f22ee00e042 in QXcbNativeInterface::getTimestamp(QXcbScreen const*) (this=this@entry=0x55cab6a508c0, screen=screen@entry=0x55cab6a562b0) at qxcbobject.h:53
#4  0x00007f22ee00f21b in QXcbNativeInterface::nativeResourceForScreen(QByteArray const&, QScreen*) (this=this@entry=0x55cab6a508c0, resourceString=..., screen=screen@entry=0x55cab6a7a110) at qxcbnativeinterface.cpp:186
#5  0x00007f22f9d13be8 in QX11Info::getTimestamp() () at qx11info_x11.cpp:302
#6  0x00007f22ec413d00 in KWin::X11StandalonePlatform::updateXTime() (this=<optimized out>) at /usr/include/qt5/QtCore/qcoreapplication.h:116
#7  0x00007f22fa056860 in KWin::Workspace::workspaceEvent(xcb_generic_event_t*) (this=0x55cab6b18f00, e=0x7f22e8003600) at /var/tmp/portage/kde-plasma/kwin-5.17.4/work/kwin-5.17.4/events.cpp:285
#8  0x00007f22f8e57334 in QAbstractEventDispatcher::filterNativeEvent(QByteArray const&, void*, long*) (this=<optimized out>, eventType=..., message=message@entry=0x7f22e8003600, result=result@entry=0x7fff42ca2eb8) at kernel/qabstracteventdispatcher.cpp:484
#9  0x00007f22edfee3d0 in QXcbConnection::handleXcbEvent(xcb_generic_event_t*) (this=this@entry=0x55cab6a56390, event=event@entry=0x7f22e8003600) at qxcbnativeinterface.h:101
#10 0x00007f22edfef136 in QXcbConnection::processXcbEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x55cab6a56390, flags=...) at qxcbconnection.cpp:1021
#11 0x00007f22ee01a36c in QXcbUnixEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x55cab6aad9c0, flags=...) at qxcbeventdispatcher.cpp:61
#12 0x00007f22f8e58a8a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=this@entry=0x7fff42ca3010, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:140
#13 0x00007f22f8e614e2 in QCoreApplication::exec() () at ../../include/QtCore/../../src/corelib/global/qflags.h:120
#14 0x00007f22fa423b17 in kdemain(int, char**) (argc=<optimized out>, argv=0x7fff42ca32a8) at /var/tmp/portage/kde-plasma/kwin-5.17.4/work/kwin-5.17.4/main_x11.cpp:474
#15 0x00007f22fa26ce3b in __libc_start_main (main=0x55cab5b2c060 <main>, argc=1, argv=0x7fff42ca32a8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fff42ca3298) at ../csu/libc-start.c:308
#16 0x000055cab5b2c09a in _start ()

Investigation of the hanged kwin_x11 process with GDB has shown that QXcbConnection::getTimestamp() never returns.
Comment 1 David Edmundson 2019-12-10 09:58:42 UTC
>Investigation of the hanged kwin_x11 process with GDB has shown that QXcbConnection::getTimestamp() never returns.

But it is active inside peekQueue?
Comment 2 Jaak Ristioja 2019-12-10 13:21:12 UTC
(In reply to David Edmundson from comment #1)
> But it is active inside peekQueue?

When I attached to the process with GDB I got this backtrace, and ran some number of "finish" commands, until it the command no longer returned. The stack frame which did not return was QXcbConnection::getTimestamp() unless I misinterpreted the output.
Comment 3 Alexander Potashev 2020-01-03 05:29:46 UTC
Same problem on Fedora 31: kwin_x11 hangs on start, consuming 100% CPU (1 CPU core).

KDE Plasma Version: 5.17.4
KDE Frameworks Version: 5.64.0
Comment 4 Alexander Potashev 2020-01-03 06:22:01 UTC
(In reply to Alexander Potashev from comment #3)
> Same problem on Fedora 31: kwin_x11 hangs on start, consuming 100% CPU (1
> CPU core).
> 
> KDE Plasma Version: 5.17.4
> KDE Frameworks Version: 5.64.0

Cannot reproduce upon reboot.

Before reboot I tried to restart kwin_x11 from command line and it hanged again. After a while I got an error like this on the command line:

"""
Couldn't start kglobalaccel from org.kde.kglobalaccel.service: QDBusError("org.freedesktop.DBus.Error.NoReply", "Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.")
"""

...however according to GDB kwin_x11 was still stuck on line 335 in kglobalaccel.cpp inside method KGlobalAccelPrivate::updateGlobalShortcut() here:
        const QList<QKeySequence> scResult(shortcutFromIntList(result));
Comment 5 Vojtěch Král 2020-07-22 09:37:09 UTC
Hi,
  it seems I'm having a very similar problem on my system.
However, in my case, this only happens upon logout and there's no noticeable CPU comsumption.
After I log out of KDE, sometimes (about 10% cases) there will be a hanging kwin_x11 process left behind, which is stuck in QXcbConnection::getTimestamp() and needs to be SIGKILLed (SIGTERM won't help). If not killed, the next login will lead to botched session where kwin and plasma fail to start, but krunner and other session components work.

Backtrace of kwin_x11 when stuck after logout:

#0  0x00007f456f3fcf04 in QXcbConnection::getTimestamp() () at /usr/lib/libQt5XcbQpa.so.5
#1  0x00007f456f418663 in QXcbNativeInterface::getTimestamp(QXcbScreen const*) () at /usr/lib/libQt5XcbQpa.so.5
#2  0x00007f456f4194e4 in QXcbNativeInterface::nativeResourceForScreen(QByteArray const&, QScreen*) () at /usr/lib/libQt5XcbQpa.so.5
#3  0x00007f457651b9c7 in QX11Info::getTimestamp() () at /usr/lib/libQt5X11Extras.so.5
#4  0x00007f45768e4619 in KWin::Platform::updateXTime() () at /usr/lib/libkwin.so.5
#5  0x00007f457689f2ec in KWin::Workspace::workspaceEvent(xcb_generic_event_t*) () at /usr/lib/libkwin.so.5
#6  0x00007f457550ec67 in QAbstractEventDispatcher::filterNativeEvent(QByteArray const&, void*, long*) () at /usr/lib/libQt5Core.so.5
#7  0x00007f456f3fb703 in QXcbConnection::handleXcbEvent(xcb_generic_event_t*) () at /usr/lib/libQt5XcbQpa.so.5
#8  0x00007f456f3fcc79 in QXcbConnection::processXcbEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5XcbQpa.so.5
#9  0x00007f456f42006e in  () at /usr/lib/libQt5XcbQpa.so.5
#10 0x00007f457551013c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#11 0x00007f45755185c4 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#12 0x000055e39cfc6412 in  ()
#13 0x00007f4574eb5002 in __libc_start_main () at /usr/lib/libc.so.6
#14 0x000055e39cfc694e in _start ()
Comment 6 ivz hh 2020-10-26 04:47:15 UTC
(In reply to Vojtěch Král from comment #5)
> Hi,
>   it seems I'm having a very similar problem on my system.
> However, in my case, this only happens upon logout and there's no noticeable
> CPU comsumption.
> After I log out of KDE, sometimes (about 10% cases) there will be a hanging
> kwin_x11 process left behind, which is stuck in
> QXcbConnection::getTimestamp() and needs to be SIGKILLed (SIGTERM won't
> help). If not killed, the next login will lead to botched session where kwin
> and plasma fail to start, but krunner and other session components work.
> 
> Backtrace of kwin_x11 when stuck after logout:
> 
> #0  0x00007f456f3fcf04 in QXcbConnection::getTimestamp() () at
> /usr/lib/libQt5XcbQpa.so.5
> #1  0x00007f456f418663 in QXcbNativeInterface::getTimestamp(QXcbScreen
> const*) () at /usr/lib/libQt5XcbQpa.so.5
> #2  0x00007f456f4194e4 in
> QXcbNativeInterface::nativeResourceForScreen(QByteArray const&, QScreen*) ()
> at /usr/lib/libQt5XcbQpa.so.5
> #3  0x00007f457651b9c7 in QX11Info::getTimestamp() () at
> /usr/lib/libQt5X11Extras.so.5
> #4  0x00007f45768e4619 in KWin::Platform::updateXTime() () at
> /usr/lib/libkwin.so.5
> #5  0x00007f457689f2ec in
> KWin::Workspace::workspaceEvent(xcb_generic_event_t*) () at
> /usr/lib/libkwin.so.5
> #6  0x00007f457550ec67 in
> QAbstractEventDispatcher::filterNativeEvent(QByteArray const&, void*, long*)
> () at /usr/lib/libQt5Core.so.5
> #7  0x00007f456f3fb703 in
> QXcbConnection::handleXcbEvent(xcb_generic_event_t*) () at
> /usr/lib/libQt5XcbQpa.so.5
> #8  0x00007f456f3fcc79 in
> QXcbConnection::processXcbEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
> at /usr/lib/libQt5XcbQpa.so.5
> #9  0x00007f456f42006e in  () at /usr/lib/libQt5XcbQpa.so.5
> #10 0x00007f457551013c in
> QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at
> /usr/lib/libQt5Core.so.5
> #11 0x00007f45755185c4 in QCoreApplication::exec() () at
> /usr/lib/libQt5Core.so.5
> #12 0x000055e39cfc6412 in  ()
> #13 0x00007f4574eb5002 in __libc_start_main () at /usr/lib/libc.so.6
> #14 0x000055e39cfc694e in _start ()

I have the same: "kwin_x11 runs infinitely on getTimestamp()". The reason is the DISPLAY is closed but `peek` cannot be notified on DISPLAY being invalidated.
Comment 7 ivz hh 2020-11-09 04:24:59 UTC
I have found a solution, I will submit a pull request soon.
Comment 9 postix 2022-05-17 13:34:35 UTC
Can you still reproduce it with some more recent Plasma version, like 5.24.5?
Comment 10 Jaak Ristioja 2022-05-17 18:57:07 UTC
A lot has changed since, but I don't remember seeing this issue for a very long while now. Might have been fixed by those merge requests. Thanks! :)