Create QApplication in a scope to work around possible deadlock
AbandonedPublic

Authored by croick on Jan 14 2019, 3:14 PM.

Details

Reviewers
sitter
Group Reviewers
KDevelop
Summary

Observed with a crashing KDevelop:
DrKonqi may be blocked by a thread in the debuggee if the
QApplication is destructed after cleanup of the DrKonqi backend.
The backend sends SIGCONT to the debuggee upon destruction.

Since DrKonqi then cannot quit, KCrash continues waiting, leading
to a deadlock. The situation may be disentangled by externally
sending SIGSTOP to the debuggee or waiting with the SIGCONT signal.

Cleaning up the QApplication first and afterwards the backend
omits the deadlock.

Test Plan
  • let kdevelop crash to fire up DrKonqi
  • close DrKonqi again
  • watch state of crashed kdevelop process

Diff Detail

Repository
R871 DrKonqi
Branch
scopedqapp
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 12567
Build 12585: arc lint + arc unit
croick created this revision.Jan 14 2019, 3:14 PM
Restricted Application added a project: Plasma. · View Herald TranscriptJan 14 2019, 3:14 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
croick requested review of this revision.Jan 14 2019, 3:14 PM

please provide some backtraces. This looks like a hack, the qa decidedly shouldn't get stuck on destruction just because cleanup already ran.

GDB
Actually the problem is about joining threads at the end of main(). After being stuck and kill -SIGSTOP $(pidof kdevelop), DrKonqi turns out to be here:

#0  0x00007fbf18adbf6d in __pthread_timedjoin_ex () from /usr/lib/libpthread.so.0
#1  0x00007fbf0aee0a01 in ?? () from /usr/lib/dri/i965_dri.so
#2  0x00007fbf0aee1299 in ?? () from /usr/lib/dri/i965_dri.so
#3  0x00007fbf0aedc76a in ?? () from /usr/lib/dri/i965_dri.so
--Type <RET> for more, q to quit, c to continue without paging--c
#4  0x00007fbf0ae66374 in ?? () from /usr/lib/dri/i965_dri.so
#5  0x00007fbf0aed83ff in ?? () from /usr/lib/dri/i965_dri.so
#6  0x00007fbf0bd4b04c in ?? () from /usr/lib/libGLX_mesa.so.0
#7  0x00007fbf0bd37822 in ?? () from /usr/lib/libGLX_mesa.so.0
#8  0x00007fbf0bd378a9 in ?? () from /usr/lib/libGLX_mesa.so.0
#9  0x00007fbf0bd379fe in ?? () from /usr/lib/libGLX_mesa.so.0
#10 0x00007fbf18d893e2 in XCloseDisplay () from /usr/lib/libX11.so.6
#11 0x00007fbf144b8fe2 in ?? () from /usr/lib/libQt5XcbQpa.so.5
#12 0x00007fbf1448e33a in QXcbConnection::~QXcbConnection() () from /usr/lib/libQt5XcbQpa.so.5
#13 0x00007fbf1448f5f7 in QXcbIntegration::~QXcbIntegration() () from /usr/lib/libQt5XcbQpa.so.5
#14 0x00007fbf1448f6fa in QXcbIntegration::~QXcbIntegration() () from /usr/lib/libQt5XcbQpa.so.5
#15 0x00007fbf1a0c5f29 in QGuiApplicationPrivate::~QGuiApplicationPrivate() () from /usr/lib/libQt5Gui.so.5
#16 0x00007fbf1a6c370a in QApplicationPrivate::~QApplicationPrivate() () from /usr/lib/libQt5Widgets.so.5
#17 0x00007fbf19d2e1cf in QObject::~QObject() () from /usr/lib/libQt5Core.so.5
#18 0x00007fbf19cfed10 in QCoreApplication::~QCoreApplication() () from /usr/lib/libQt5Core.so.5
#19 0x00007fbf1a6c5852 in QApplication::~QApplication() () from /usr/lib/libQt5Widgets.so.5
#20 0x0000558afb850900 in main (argc=<optimized out>, argv=<optimized out>) at /home/christoph/Software/kde/kde/workspace/drkonqi/src/main.cpp:148

strace

  • $ kill -SIGSEGV $(pidof kdevelop)
  • let DrKonqi fire up
  • $ strace -fp $(pidof drkonqi)
    • strace: Process 9554 attached with 4 threads
  • close the DrKonqi dialog

strace output:

.
.
.
[pid  9556] poll([{fd=7, events=POLLIN}, {fd=8, events=POLLIN}], 2, -1 <unfinished ...>
[pid  9554] <... poll resumed> )        = 1 ([{fd=3, revents=POLLOUT}])
[pid  9554] writev(3, [{iov_base="<\0\2\0\20\0@\0106\0\2\0\17\0@\10\206\6\2\0\10\0@\10\4\0\2\0\7\0@\10"..., iov_len=124}], 1) = 124
[pid  9554] futex(0x55aa7e92a300, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid  9555] <... poll resumed> )        = 1 ([{fd=3, revents=POLLIN}])
[pid  9555] recvmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\22\08\3\7\0@\10\7\0@\10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 64
[pid  9555] poll([{fd=3, events=POLLIN}], 1, -1) = 1 ([{fd=3, revents=POLLIN}])
[pid  9555] recvmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\t\58\3\7\0@\10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32
[pid  9555] poll([{fd=3, events=POLLIN}], 1, -1) = 1 ([{fd=3, revents=POLLIN}])
[pid  9555] recvmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\10\08\3\25\332I\0H\1\0\0\7\0@\10\0\0\0\0\233\3\225\1L\2)\1\20\0\0\3"..., iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 108
[pid  9555] poll([{fd=3, events=POLLIN}], 1, -1) = 1 ([{fd=3, revents=POLLIN}])
[pid  9555] recvmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\21\08\3\7\0@\10\7\0@\10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 928
[pid  9555] poll([{fd=3, events=POLLIN}], 1, -1) = 1 ([{fd=3, revents=POLLIN}])
[pid  9555] recvmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\241 ;\3\21\0@\10Q\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32
[pid  9555] close(4)                    = 0
[pid  9555] futex(0x55aa7e92a300, FUTEX_WAKE_PRIVATE, 2147483647) = 1
[pid  9555] madvise(0x7f5dab453000, 8368128, MADV_DONTNEED) = 0
[pid  9555] exit(0)                     = ?
[pid  9555] +++ exited with 0 +++
[pid  9554] <... futex resumed> )       = 0
[pid  9554] futex(0x55aa7e92a2b0, FUTEX_WAKE_PRIVATE, 1) = 0
[pid  9554] poll([{fd=3, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=3, revents=POLLIN|POLLOUT}])
[pid  9554] recvmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\34\0<\3H\1\0\0\204\1\0\0\33\332I\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32
[pid  9554] writev(3, [{iov_base=".\0\2\0\3\0@\10_\0\2\0\f\0@\10", iov_len=16}], 1) = 16
[pid  9554] poll([{fd=3, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=3, revents=POLLOUT}])
[pid  9554] writev(3, [{iov_base="<\27\2\0\0\0@\10+\0\1\0", iov_len=12}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 12
[pid  9554] poll([{fd=3, events=POLLIN}], 1, -1) = 1 ([{fd=3, revents=POLLIN}])
[pid  9554] recvmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\34\0<\3H\1\0\0\266\1\0\0\35\332I\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32
[pid  9554] poll([{fd=3, events=POLLIN}], 1, -1) = 1 ([{fd=3, revents=POLLIN}])
[pid  9554] recvmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\34\0<\3H\1\0\0\267\1\0\0\35\332I\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 96
[pid  9554] futex(0x55aa7ea93ac8, FUTEX_WAKE_PRIVATE, 2147483647) = 1
[pid  9554] futex(0x7f5da2df59d0, FUTEX_WAIT, 9557, NULL

Afterwards nothing happens, the CPU is (endlessly) busy doing something for kdevelop. Note how poll() in thread 9556 (QDBusConnection) never returned and is finally blocking the other threads.
The FD 7 points to 'anon_inode:[eventfd]'

  • $ kill -SIGSTOP $(pidof kdevelop)

strace output now resumes:

[pid  9557] <... futex resumed> )       = 0
[pid  9557] futex(0x55aa7ea93a78, FUTEX_WAKE_PRIVATE, 1) = 0
[pid  9557] madvise(0x7f5da25f5000, 8368128, MADV_DONTNEED) = 0
[pid  9557] exit(0)                     = ?
[pid  9557] +++ exited with 0 +++
[pid  9554] <... futex resumed> )       = 0
[pid  9554] munmap(0x7f5da2df6000, 1310728) = 0
[pid  9554] close(13)                   = 0
[pid  9554] shutdown(3, SHUT_RDWR)      = 0
[pid  9554] close(3)                    = 0
[pid  9554] write(7, "\1\0\0\0\0\0\0\0", 8) = 8
[pid  9556] <... poll resumed> )        = 1 ([{fd=7, revents=POLLIN}])
.
.
.
[pid  9556] exit(0)                     = ?
[pid  9556] +++ exited with 0 +++
getpid()                                = 9554
exit_group(0)                           = ?
+++ exited with 0 +++

kdevelop
stracing the kdevelop process at the same time shows, that a thread called "QQuickXmlQueryE" is blocked by a read()-syscall also with an eventfd.
Actually all files are directly closed by KCrash, but as far as I understand the epoll mechanism, the epoll instance remains as long as there are processes using it, so close() might not have the desired effect.
Might be that DrKonqi and KDevelop are trying to read from the same file. I cannot tell. https://patchwork.kernel.org/patch/10413589/ is not part of the kernel yet it seems.

Actually, by using KCrash::setFlags(KCrash::KeepFDs) in KDevelop, so preventing the closing of all FDs, the problem is fixed(?) as well.
But I think, that the situation should not appear, even for a "misconfigured" debuggee.

Please paste the backtraces of all threads of drkonqi (assuming that is actually stuck as well?) and the backtraces of all threads of kdevelop (assuming that is stuck?).

The following steps allow creating the backtraces. Simply attaching to KDevelop does not work, since that sends a SIGSTOP to all threads (and releases the dead lock). Attaching to DrKonqi after closing the dialog does not work since the process already is defunct:

  • kill -SIGSEGV $(pidof kdevelop)
  • raise DrKonqi dialog
  • gdb -p $(pidof drkonqi), continue execution
  • close DrKonqi dialog
  • CTRL + C in gdb, which now is stuck
  • kill -SIGSTOP $(pidof kdevelop), gdb reacts again, generate backtrace for DrKonqi
  • gdb -p $(pidof kdevelop), generate backtrace for KDevelop

Backtrace of DrKonqi:

(gdb) info thread
  Id   Target Id                                           Frame 
  1    Thread 0x7f123713bcc0 (LWP 17330) "drkonqi"         0x00007f123b0a6f6d in __pthread_timedjoin_ex () from /usr/lib/libpthread.so.0
* 3    Thread 0x7f122ffff700 (LWP 17332) "QDBusConnection" 0x00007f123bc65c21 in poll () from /usr/lib/libc.so.6
  4    Thread 0x7f122d866700 (LWP 17333) "drkonqi:disk$0"  0x00007f123b0abafc in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /usr/lib/libpthread.so.0
(gdb) thread apply all bt

Thread 4 (Thread 0x7f122d866700 (LWP 17333)):
#0  0x00007f123b0abafc in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007f122de63c84 in ?? () from /usr/lib/dri/i965_dri.so
#2  0x00007f122de639a8 in ?? () from /usr/lib/dri/i965_dri.so
#3  0x00007f123b0a5a9d in start_thread () from /usr/lib/libpthread.so.0
#4  0x00007f123bc70b23 in clone () from /usr/lib/libc.so.6

Thread 3 (Thread 0x7f122ffff700 (LWP 17332)):
#0  0x00007f123bc65c21 in poll () from /usr/lib/libc.so.6
#1  0x00007f123a063540 in ?? () from /usr/lib/libglib-2.0.so.0
#2  0x00007f123a06362e in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#3  0x00007f123c337ce9 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#4  0x00007f123c2e0b2c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#5  0x00007f123c124569 in QThread::exec() () from /usr/lib/libQt5Core.so.5
#6  0x00007f123d21dba6 in ?? () from /usr/lib/libQt5DBus.so.5
#7  0x00007f123c12596c in ?? () from /usr/lib/libQt5Core.so.5
#8  0x00007f123b0a5a9d in start_thread () from /usr/lib/libpthread.so.0
#9  0x00007f123bc70b23 in clone () from /usr/lib/libc.so.6

Thread 1 (Thread 0x7f123713bcc0 (LWP 17330)):
#0  0x00007f123b0a6f6d in __pthread_timedjoin_ex () from /usr/lib/libpthread.so.0
#1  0x00007f122de63a61 in ?? () from /usr/lib/dri/i965_dri.so
#2  0x00007f122de642f9 in ?? () from /usr/lib/dri/i965_dri.so
#3  0x00007f122de5f72a in ?? () from /usr/lib/dri/i965_dri.so
#4  0x00007f122dde9334 in ?? () from /usr/lib/dri/i965_dri.so
#5  0x00007f122de5b3bf in ?? () from /usr/lib/dri/i965_dri.so
#6  0x00007f122ecee07c in ?? () from /usr/lib/libGLX_mesa.so.0
#7  0x00007f122ecda822 in ?? () from /usr/lib/libGLX_mesa.so.0
#8  0x00007f122ecda8a9 in ?? () from /usr/lib/libGLX_mesa.so.0
#9  0x00007f122ecda9fe in ?? () from /usr/lib/libGLX_mesa.so.0
#10 0x00007f123b3543e2 in XCloseDisplay () from /usr/lib/libX11.so.6
#11 0x00007f1236c8af52 in ?? () from /usr/lib/libQt5XcbQpa.so.5
#12 0x00007f1236c6011a in QXcbConnection::~QXcbConnection() () from /usr/lib/libQt5XcbQpa.so.5
#13 0x00007f1236c613d7 in QXcbIntegration::~QXcbIntegration() () from /usr/lib/libQt5XcbQpa.so.5
#14 0x00007f1236c614da in QXcbIntegration::~QXcbIntegration() () from /usr/lib/libQt5XcbQpa.so.5
#15 0x00007f123c6abed9 in QGuiApplicationPrivate::~QGuiApplicationPrivate() () from /usr/lib/libQt5Gui.so.5
#16 0x00007f123ccaa6fa in QApplicationPrivate::~QApplicationPrivate() () from /usr/lib/libQt5Widgets.so.5
#17 0x00007f123c31386f in QObject::~QObject() () from /usr/lib/libQt5Core.so.5
#18 0x00007f123c2e42b0 in QCoreApplication::~QCoreApplication() () from /usr/lib/libQt5Core.so.5
#19 0x00007f123ccac842 in QApplication::~QApplication() () from /usr/lib/libQt5Widgets.so.5
#20 0x0000562218057e23 in main ()

Backtrace of KDevelop:

(gdb) info thread
  Id   Target Id                                           Frame 
* 1    Thread 0x7fb1d60d8440 (LWP 16624) "kdevelop"        0x00007fb1ea770c21 in poll () from /usr/lib/libc.so.6
  2    Thread 0x7fb1d531f700 (LWP 16625) "QXcbEventQueue"  0x00007fb1ea770c21 in poll () from /usr/lib/libc.so.6
  3    Thread 0x7fb1cf060700 (LWP 16626) "kdevelo:disk$0"  0x00007fb1e99cdafc in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /usr/lib/libpthread.so.0
  4    Thread 0x7fb1cd4ae700 (LWP 16627) "QDBusConnection" 0x00007fb1eefc64f9 in _dl_update_slotinfo () from /lib64/ld-linux-x86-64.so.2
  5    Thread 0x7fb1c4c8d700 (LWP 16629) "QThread"         0x00007fb1ea770c21 in poll () from /usr/lib/libc.so.6
  6    Thread 0x7fb1b784f700 (LWP 16642) "kdevelop"        0x00007fb1e99cdafc in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /usr/lib/libpthread.so.0
  7    Thread 0x7fb1b6725700 (LWP 16643) "QQmlThread"      0x00007fb1e7eec424 in g_mutex_unlock () from /usr/lib/libglib-2.0.so.0
  8    Thread 0x7fb1affff700 (LWP 16645) "KDevelop::Compl" 0x00007fb1e7eec424 in g_mutex_unlock () from /usr/lib/libglib-2.0.so.0
  9    Thread 0x7fb1af4ee700 (LWP 16646) "OutputFilterThr" 0x00007fb1ea770c21 in poll () from /usr/lib/libc.so.6
  10   Thread 0x7fb1ae261700 (LWP 16648) "Qt bearer threa" 0x00007fb1e7eec3b9 in g_mutex_lock () from /usr/lib/libglib-2.0.so.0
  11   Thread 0x7fb1ad381700 (LWP 16652) "KDevelop::Compl" 0x00007fb1eae45078 in ?? () from /usr/lib/libQt5Core.so.5
  12   Thread 0x7fb161ffb700 (LWP 17238) "QQuickXmlQueryE" 0x00007fb1ea76c7a4 in read () from /usr/lib/libc.so.6
  13   Thread 0x7fb19f0bb700 (LWP 17264) "Queue(0x55ffc08" 0x00007fb1e99cdafc in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /usr/lib/libpthread.so.0
  14   Thread 0x7fb1827fc700 (LWP 17265) "Queue(0x55ffc08" 0x00007fb1e99cdafc in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /usr/lib/libpthread.so.0
  15   Thread 0x7fb19f8bc700 (LWP 17266) "Queue(0x55ffc08" 0x00007fb1e99cdafc in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /usr/lib/libpthread.so.0
  16   Thread 0x7fb19e8ba700 (LWP 17267) "Queue(0x55ffc08" 0x00007fb1e99cdafc in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /usr/lib/libpthread.so.0
  17   Thread 0x7fb19e0b9700 (LWP 17268) "Queue(0x55ffc08" 0x00007fb1e99cdafc in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /usr/lib/libpthread.so.0
(gdb) thread apply all bt

Thread 17 (Thread 0x7fb19e0b9700 (LWP 17268)):
#0  0x00007fb1e99cdafc in pthread_cond_wait@@GLIBC_2.3.2 () at /usr/lib/libpthread.so.0
#1  0x00007fb1eac38c4c in QWaitCondition::wait(QMutex*, QDeadlineTimer) () at /usr/lib/libQt5Core.so.5
#2  0x00007fb1eac38d3a in QWaitCondition::wait(QMutex*, unsigned long) () at /usr/lib/libQt5Core.so.5
#3  0x00007fb1edba2d66 in ThreadWeaver::Weaver::blockThreadUntilJobsAreBeingAssigned_locked(ThreadWeaver::Thread*) ()
    at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#4  0x00007fb1edba2b0b in ThreadWeaver::Weaver::takeFirstAvailableJobOrSuspendOrWait(ThreadWeaver::Thread*, bool, bool, bool) ()
    at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#5  0x00007fb1edbaaf01 in ThreadWeaver::WorkingHardState::applyForWork(ThreadWeaver::Thread*, bool) ()
    at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#6  0x00007fb1edba2c0f in ThreadWeaver::Weaver::applyForWork(ThreadWeaver::Thread*, bool) ()
    at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#7  0x00007fb1edba76a5 in ThreadWeaver::Thread::run() () at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#8  0x00007fb1eac3296c in  () at /usr/lib/libQt5Core.so.5
#9  0x00007fb1e99c7a9d in start_thread () at /usr/lib/libpthread.so.0
#10 0x00007fb1ea77bb23 in clone () at /usr/lib/libc.so.6

Thread 16 (Thread 0x7fb19e8ba700 (LWP 17267)):
#0  0x00007fb1e99cdafc in pthread_cond_wait@@GLIBC_2.3.2 () at /usr/lib/libpthread.so.0
#1  0x00007fb1eac38c4c in QWaitCondition::wait(QMutex*, QDeadlineTimer) () at /usr/lib/libQt5Core.so.5
#2  0x00007fb1eac38d3a in QWaitCondition::wait(QMutex*, unsigned long) () at /usr/lib/libQt5Core.so.5
#3  0x00007fb1edba2d66 in ThreadWeaver::Weaver::blockThreadUntilJobsAreBeingAssigned_locked(ThreadWeaver::Thread*) ()
    at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#4  0x00007fb1edba2b0b in ThreadWeaver::Weaver::takeFirstAvailableJobOrSuspendOrWait(ThreadWeaver::Thread*, bool, bool, bool) ()
    at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#5  0x00007fb1edbaaf01 in ThreadWeaver::WorkingHardState::applyForWork(ThreadWeaver::Thread*, bool) ()
    at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#6  0x00007fb1edba2c0f in ThreadWeaver::Weaver::applyForWork(ThreadWeaver::Thread*, bool) ()
--Type <RET> for more, q to quit, c to continue without paging--c
    at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#7  0x00007fb1edba76a5 in ThreadWeaver::Thread::run() () at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#8  0x00007fb1eac3296c in  () at /usr/lib/libQt5Core.so.5
#9  0x00007fb1e99c7a9d in start_thread () at /usr/lib/libpthread.so.0
#10 0x00007fb1ea77bb23 in clone () at /usr/lib/libc.so.6

Thread 15 (Thread 0x7fb19f8bc700 (LWP 17266)):
#0  0x00007fb1e99cdafc in pthread_cond_wait@@GLIBC_2.3.2 () at /usr/lib/libpthread.so.0
#1  0x00007fb1eac38c4c in QWaitCondition::wait(QMutex*, QDeadlineTimer) () at /usr/lib/libQt5Core.so.5
#2  0x00007fb1eac38d3a in QWaitCondition::wait(QMutex*, unsigned long) () at /usr/lib/libQt5Core.so.5
#3  0x00007fb1edba2d66 in ThreadWeaver::Weaver::blockThreadUntilJobsAreBeingAssigned_locked(ThreadWeaver::Thread*) () at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#4  0x00007fb1edba2b0b in ThreadWeaver::Weaver::takeFirstAvailableJobOrSuspendOrWait(ThreadWeaver::Thread*, bool, bool, bool) () at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#5  0x00007fb1edbaaf01 in ThreadWeaver::WorkingHardState::applyForWork(ThreadWeaver::Thread*, bool) () at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#6  0x00007fb1edba2c0f in ThreadWeaver::Weaver::applyForWork(ThreadWeaver::Thread*, bool) () at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#7  0x00007fb1edba76a5 in ThreadWeaver::Thread::run() () at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#8  0x00007fb1eac3296c in  () at /usr/lib/libQt5Core.so.5
#9  0x00007fb1e99c7a9d in start_thread () at /usr/lib/libpthread.so.0
#10 0x00007fb1ea77bb23 in clone () at /usr/lib/libc.so.6

Thread 14 (Thread 0x7fb1827fc700 (LWP 17265)):
#0  0x00007fb1e99cdafc in pthread_cond_wait@@GLIBC_2.3.2 () at /usr/lib/libpthread.so.0
#1  0x00007fb1eac38c4c in QWaitCondition::wait(QMutex*, QDeadlineTimer) () at /usr/lib/libQt5Core.so.5
#2  0x00007fb1eac38d3a in QWaitCondition::wait(QMutex*, unsigned long) () at /usr/lib/libQt5Core.so.5
#3  0x00007fb1edba2d66 in ThreadWeaver::Weaver::blockThreadUntilJobsAreBeingAssigned_locked(ThreadWeaver::Thread*) () at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#4  0x00007fb1edba2b0b in ThreadWeaver::Weaver::takeFirstAvailableJobOrSuspendOrWait(ThreadWeaver::Thread*, bool, bool, bool) () at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#5  0x00007fb1edbaaf01 in ThreadWeaver::WorkingHardState::applyForWork(ThreadWeaver::Thread*, bool) () at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#6  0x00007fb1edba2c0f in ThreadWeaver::Weaver::applyForWork(ThreadWeaver::Thread*, bool) () at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#7  0x00007fb1edba76a5 in ThreadWeaver::Thread::run() () at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#8  0x00007fb1eac3296c in  () at /usr/lib/libQt5Core.so.5
#9  0x00007fb1e99c7a9d in start_thread () at /usr/lib/libpthread.so.0
#10 0x00007fb1ea77bb23 in clone () at /usr/lib/libc.so.6

Thread 13 (Thread 0x7fb19f0bb700 (LWP 17264)):
#0  0x00007fb1e99cdafc in pthread_cond_wait@@GLIBC_2.3.2 () at /usr/lib/libpthread.so.0
#1  0x00007fb1eac38c4c in QWaitCondition::wait(QMutex*, QDeadlineTimer) () at /usr/lib/libQt5Core.so.5
#2  0x00007fb1eac38d3a in QWaitCondition::wait(QMutex*, unsigned long) () at /usr/lib/libQt5Core.so.5
#3  0x00007fb1edba2d66 in ThreadWeaver::Weaver::blockThreadUntilJobsAreBeingAssigned_locked(ThreadWeaver::Thread*) () at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#4  0x00007fb1edba2b0b in ThreadWeaver::Weaver::takeFirstAvailableJobOrSuspendOrWait(ThreadWeaver::Thread*, bool, bool, bool) () at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#5  0x00007fb1edbaaf01 in ThreadWeaver::WorkingHardState::applyForWork(ThreadWeaver::Thread*, bool) () at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#6  0x00007fb1edba2c0f in ThreadWeaver::Weaver::applyForWork(ThreadWeaver::Thread*, bool) () at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#7  0x00007fb1edba76a5 in ThreadWeaver::Thread::run() () at /home/christoph/kde-latest/lib64/libKF5ThreadWeaver.so.5
#8  0x00007fb1eac3296c in  () at /usr/lib/libQt5Core.so.5
#9  0x00007fb1e99c7a9d in start_thread () at /usr/lib/libpthread.so.0
#10 0x00007fb1ea77bb23 in clone () at /usr/lib/libc.so.6

Thread 12 (Thread 0x7fb161ffb700 (LWP 17238)):
#0  0x00007fb1ea76c7a4 in read () at /usr/lib/libc.so.6
#1  0x00007fb1e7eec971 in  () at /usr/lib/libglib-2.0.so.0
#2  0x00007fb1e7f3d0b0 in g_main_context_check () at /usr/lib/libglib-2.0.so.0
#3  0x00007fb1e7f3e4e6 in  () at /usr/lib/libglib-2.0.so.0
#4  0x00007fb1e7f3e62e in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#5  0x00007fb1eae44d04 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#6  0x00007fb1eadedb2c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#7  0x00007fb1eac31569 in QThread::exec() () at /usr/lib/libQt5Core.so.5
#8  0x00007fb1ac8be3da in  () at /usr/lib/qt/qml/QtQuick/XmlListModel/libqmlxmllistmodelplugin.so
#9  0x00007fb1eac3296c in  () at /usr/lib/libQt5Core.so.5
#10 0x00007fb1e99c7a9d in start_thread () at /usr/lib/libpthread.so.0
#11 0x00007fb1ea77bb23 in clone () at /usr/lib/libc.so.6

Thread 11 (Thread 0x7fb1ad381700 (LWP 16652)):
#0  0x00007fb1eae45078 in  () at /usr/lib/libQt5Core.so.5
#1  0x00007fb1e7f3de0a in g_main_context_prepare () at /usr/lib/libglib-2.0.so.0
#2  0x00007fb1e7f3e466 in  () at /usr/lib/libglib-2.0.so.0
#3  0x00007fb1e7f3e62e in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#4  0x00007fb1eae44d04 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#5  0x00007fb1eadedb2c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#6  0x00007fb1eac31569 in QThread::exec() () at /usr/lib/libQt5Core.so.5
#7  0x00007fb1eddea940 in KDevelop::CompletionWorkerThread::run() () at /home/christoph/kde-latest/lib64/libKDevPlatformLanguage.so.54
#8  0x00007fb1eac3296c in  () at /usr/lib/libQt5Core.so.5
#9  0x00007fb1e99c7a9d in start_thread () at /usr/lib/libpthread.so.0
#10 0x00007fb1ea77bb23 in clone () at /usr/lib/libc.so.6

Thread 10 (Thread 0x7fb1ae261700 (LWP 16648)):
#0  0x00007fb1e7eec3b9 in g_mutex_lock () at /usr/lib/libglib-2.0.so.0
#1  0x00007fb1e7f3e619 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#2  0x00007fb1eae44d04 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#3  0x00007fb1eadedb2c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#4  0x00007fb1eac31569 in QThread::exec() () at /usr/lib/libQt5Core.so.5
#5  0x00007fb1eac3296c in  () at /usr/lib/libQt5Core.so.5
#6  0x00007fb1e99c7a9d in start_thread () at /usr/lib/libpthread.so.0
#7  0x00007fb1ea77bb23 in clone () at /usr/lib/libc.so.6

Thread 9 (Thread 0x7fb1af4ee700 (LWP 16646)):
#0  0x00007fb1ea770c21 in poll () at /usr/lib/libc.so.6
#1  0x00007fb1e7f3e540 in  () at /usr/lib/libglib-2.0.so.0
#2  0x00007fb1e7f3e62e in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#3  0x00007fb1eae44d04 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#4  0x00007fb1eadedb2c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#5  0x00007fb1eac31569 in QThread::exec() () at /usr/lib/libQt5Core.so.5
#6  0x00007fb1eac3296c in  () at /usr/lib/libQt5Core.so.5
#7  0x00007fb1e99c7a9d in start_thread () at /usr/lib/libpthread.so.0
#8  0x00007fb1ea77bb23 in clone () at /usr/lib/libc.so.6

Thread 8 (Thread 0x7fb1affff700 (LWP 16645)):
#0  0x00007fb1e7eec424 in g_mutex_unlock () at /usr/lib/libglib-2.0.so.0
#1  0x00007fb1e7f3ddfd in g_main_context_prepare () at /usr/lib/libglib-2.0.so.0
#2  0x00007fb1e7f3e466 in  () at /usr/lib/libglib-2.0.so.0
#3  0x00007fb1e7f3e62e in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#4  0x00007fb1eae44d04 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#5  0x00007fb1eadedb2c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#6  0x00007fb1eac31569 in QThread::exec() () at /usr/lib/libQt5Core.so.5
#7  0x00007fb1eddea940 in KDevelop::CompletionWorkerThread::run() () at /home/christoph/kde-latest/lib64/libKDevPlatformLanguage.so.54
#8  0x00007fb1eac3296c in  () at /usr/lib/libQt5Core.so.5
#9  0x00007fb1e99c7a9d in start_thread () at /usr/lib/libpthread.so.0
#10 0x00007fb1ea77bb23 in clone () at /usr/lib/libc.so.6

Thread 7 (Thread 0x7fb1b6725700 (LWP 16643)):
#0  0x00007fb1e7eec424 in g_mutex_unlock () at /usr/lib/libglib-2.0.so.0
#1  0x00007fb1e7f3ddfd in g_main_context_prepare () at /usr/lib/libglib-2.0.so.0
#2  0x00007fb1e7f3e466 in  () at /usr/lib/libglib-2.0.so.0
#3  0x00007fb1e7f3e62e in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#4  0x00007fb1eae44d04 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#5  0x00007fb1eadedb2c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#6  0x00007fb1eac31569 in QThread::exec() () at /usr/lib/libQt5Core.so.5
#7  0x00007fb1ecdcd969 in  () at /usr/lib/libQt5Qml.so.5
#8  0x00007fb1eac3296c in  () at /usr/lib/libQt5Core.so.5
#9  0x00007fb1e99c7a9d in start_thread () at /usr/lib/libpthread.so.0
#10 0x00007fb1ea77bb23 in clone () at /usr/lib/libc.so.6

Thread 6 (Thread 0x7fb1b784f700 (LWP 16642)):
#0  0x00007fb1e99cdafc in pthread_cond_wait@@GLIBC_2.3.2 () at /usr/lib/libpthread.so.0
#1  0x00007fb1eaa9acd1 in __gthread_cond_wait (__mutex=<optimized out>, __cond=<optimized out>) at /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:864
#2  0x00007fb1eaa9acd1 in std::condition_variable::wait(std::unique_lock<std::mutex>&) (this=<optimized out>, __lock=...) at /build/gcc/src/gcc/libstdc++-v3/src/c++11/condition_variable.cc:53
#3  0x00007fb1ba872f14 in  () at /usr/lib/libQt5WebKit.so.5
#4  0x00007fb1ba873039 in  () at /usr/lib/libQt5WebKit.so.5
#5  0x00007fb1eaaa1063 in std::execute_native_thread_routine(void*) (__p=0x55ffc0b1ce30) at /build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:80
#6  0x00007fb1e99c7a9d in start_thread () at /usr/lib/libpthread.so.0
#7  0x00007fb1ea77bb23 in clone () at /usr/lib/libc.so.6

Thread 5 (Thread 0x7fb1c4c8d700 (LWP 16629)):
#0  0x00007fb1ea770c21 in poll () at /usr/lib/libc.so.6
#1  0x00007fb1e7f3e540 in  () at /usr/lib/libglib-2.0.so.0
#2  0x00007fb1e7f3e62e in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#3  0x00007fb1eae44d04 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#4  0x00007fb1eadedb2c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#5  0x00007fb1eac31569 in QThread::exec() () at /usr/lib/libQt5Core.so.5
#6  0x00007fb1edca2733 in KDevelop::DUChainPrivate::CleanupThread::run() () at /home/christoph/kde-latest/lib64/libKDevPlatformLanguage.so.54
#7  0x00007fb1eac3296c in  () at /usr/lib/libQt5Core.so.5
#8  0x00007fb1e99c7a9d in start_thread () at /usr/lib/libpthread.so.0
#9  0x00007fb1ea77bb23 in clone () at /usr/lib/libc.so.6

Thread 4 (Thread 0x7fb1cd4ae700 (LWP 16627)):
#0  0x00007fb1eefc64f9 in _dl_update_slotinfo () at /lib64/ld-linux-x86-64.so.2
#1  0x00007fb1eefc656c in update_get_addr () at /lib64/ld-linux-x86-64.so.2
#2  0x00007fb1eefcb47c in __tls_get_addr () at /lib64/ld-linux-x86-64.so.2
#3  0x00007fb1eac31c57 in  () at /usr/lib/libQt5Core.so.5
#4  0x00007fb1eae451b2 in  () at /usr/lib/libQt5Core.so.5
#5  0x00007fb1e7f3cfb2 in g_main_context_check () at /usr/lib/libglib-2.0.so.0
#6  0x00007fb1e7f3e4e6 in  () at /usr/lib/libglib-2.0.so.0
#7  0x00007fb1e7f3e62e in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#8  0x00007fb1eae44d04 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#9  0x00007fb1eadedb2c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#10 0x00007fb1eac31569 in QThread::exec() () at /usr/lib/libQt5Core.so.5
#11 0x00007fb1eb99dba6 in  () at /usr/lib/libQt5DBus.so.5
#12 0x00007fb1eac3296c in  () at /usr/lib/libQt5Core.so.5
#13 0x00007fb1e99c7a9d in start_thread () at /usr/lib/libpthread.so.0
#14 0x00007fb1ea77bb23 in clone () at /usr/lib/libc.so.6

Thread 3 (Thread 0x7fb1cf060700 (LWP 16626)):
#0  0x00007fb1e99cdafc in pthread_cond_wait@@GLIBC_2.3.2 () at /usr/lib/libpthread.so.0
#1  0x00007fb1cf5fcc84 in  () at /usr/lib/dri/i965_dri.so
#2  0x00007fb1cf5fc9a8 in  () at /usr/lib/dri/i965_dri.so
#3  0x00007fb1e99c7a9d in start_thread () at /usr/lib/libpthread.so.0
#4  0x00007fb1ea77bb23 in clone () at /usr/lib/libc.so.6

Thread 2 (Thread 0x7fb1d531f700 (LWP 16625)):
#0  0x00007fb1ea770c21 in poll () at /usr/lib/libc.so.6
#1  0x00007fb1e0ee8630 in  () at /usr/lib/libxcb.so.1
#2  0x00007fb1e0eea2db in xcb_wait_for_event () at /usr/lib/libxcb.so.1
#3  0x00007fb1d5c22949 in  () at /usr/lib/libQt5XcbQpa.so.5
#4  0x00007fb1eac3296c in  () at /usr/lib/libQt5Core.so.5
#5  0x00007fb1e99c7a9d in start_thread () at /usr/lib/libpthread.so.0
#6  0x00007fb1ea77bb23 in clone () at /usr/lib/libc.so.6

Thread 1 (Thread 0x7fb1d60d8440 (LWP 16624)):
#0  0x00007fb1ea770c21 in poll () at /usr/lib/libc.so.6
#1  0x00007fb1ec41cedb in pollDrKonqiSocket(int, int) () at /home/christoph/kde-latest/lib64/libKF5Crash.so.5
#2  0x00007fb1ec41c56b in startProcessInternal(int, char const**, bool, bool) () at /home/christoph/kde-latest/lib64/libKF5Crash.so.5
#3  0x00007fb1ec41c275 in KCrash::startProcess(int, char const**, bool) () at /home/christoph/kde-latest/lib64/libKF5Crash.so.5
#4  0x00007fb1ec41c15c in KCrash::defaultCrashHandler(int) () at /home/christoph/kde-latest/lib64/libKF5Crash.so.5
#5  0x00007fb1ea6b7e00 in <signal handler called> () at /usr/lib/libc.so.6
#6  0x00007fb1ea770c21 in poll () at /usr/lib/libc.so.6
#7  0x00007fb1e7f3e540 in  () at /usr/lib/libglib-2.0.so.0
#8  0x00007fb1e7f3e62e in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#9  0x00007fb1eae44ce9 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#10 0x00007fb1eadedb2c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#11 0x00007fb1eadf5e36 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#12 0x000055ffbef2b398 in main ()
croick added a subscriber: ossi.Feb 22 2019, 10:21 PM

I dug in the history of KCrash and realized, that closing all the file descriptors was introduced (7bbf112e5e97d40b9a4f9fdd167b064a1019843b) to make the X11 window disappear.
Later @ossi added the X11 FD explicitly (7ac326ddb05eec296fdfbebd86d0d1320e579063), but kept closing the FDs by default.

I think keeping the FDs should be the default. However, the only program I found that is explicitly setting KCrash::CrashFlag::KeepFDs is Falkon, the rest seems to be fine without (except me with KDevelop).

the patch definitely looks like a hack, but i'll leave the final judgment on that to thiago.

kcrash closes all file descriptors to make the crashed process appear "as gone as possible" to anyone who might have wanted to talk to it, so possible waiters get EOF, etc.
obviously, if new kernel apis introduced ipc objects which are not (fully) disposed of by closing fds, these should be taken care of explicitly as well.

The patch is innocuous. I don't see *how* it can solve anything, though, because I don;'t know what DrKonqu::cleanup does.

The commit message is nonsense. This problem has nothing to do with D-Bus. That's a red herring, because the QDBusConnection thread only exits after all open QDBusConnections close (including QDBusMessages holding them). The problem appears to be the XCB thread, stuck waiting for something, somehow, inside XCloseDisplay.

The problem does not seem to be specific to DrKonqi. Once DrKonqi and KDevelop are stuck, any Qt program may have problems starting or quitting. A minimal example

#include <QApplication>
#include <QWidget>

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QWidget().show();

    return 0;
}

gets stuck as well (sometimes starting like below, sometimes only when quitting), as long as KDevelop was not SIGSTOPped.

(gdb) info thread
  Id   Target Id                                          Frame 
* 1    Thread 0x7ffff36a2f80 (LWP 21781) "testqt"         0x00007ffff6a116eb in brk () from /usr/lib/libc.so.6
  2    Thread 0x7ffff2346700 (LWP 21785) "QXcbEventQueue" 0x00007ffff6a0fc21 in poll () from /usr/lib/libc.so.6
  3    Thread 0x7fffe9642700 (LWP 21786) "testqt:disk$0"  0x00007ffff690bafc in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /usr/lib/libpthread.so.0
(gdb) thread apply all bt

Thread 3 (Thread 0x7fffe9642700 (LWP 21786)):
#0  0x00007ffff690bafc in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007fffe9c5ec94 in ?? () from /usr/lib/dri/i965_dri.so
#2  0x00007fffe9c5e9b8 in ?? () from /usr/lib/dri/i965_dri.so
#3  0x00007ffff6905a9d in start_thread () from /usr/lib/libpthread.so.0
#4  0x00007ffff6a1ab23 in clone () from /usr/lib/libc.so.6

Thread 2 (Thread 0x7ffff2346700 (LWP 21785)):
#0  0x00007ffff6a0fc21 in poll () from /usr/lib/libc.so.6
#1  0x00007ffff38f5630 in ?? () from /usr/lib/libxcb.so.1
#2  0x00007ffff38f72db in xcb_wait_for_event () from /usr/lib/libxcb.so.1
#3  0x00007ffff31f0949 in ?? () from /usr/lib/libQt5XcbQpa.so.5
#4  0x00007ffff6ed196c in ?? () from /usr/lib/libQt5Core.so.5
#5  0x00007ffff6905a9d in start_thread () from /usr/lib/libpthread.so.0
#6  0x00007ffff6a1ab23 in clone () from /usr/lib/libc.so.6

Thread 1 (Thread 0x7ffff36a2f80 (LWP 21781)):
#0  0x00007ffff6a116eb in brk () from /usr/lib/libc.so.6
#1  0x00007ffff6a117d1 in sbrk () from /usr/lib/libc.so.6
#2  0x00007ffff69a63ed in __default_morecore () from /usr/lib/libc.so.6
#3  0x00007ffff69a2656 in sysmalloc () from /usr/lib/libc.so.6
#4  0x00007ffff69a3716 in _int_malloc () from /usr/lib/libc.so.6
#5  0x00007ffff69a4ada in malloc () from /usr/lib/libc.so.6
#6  0x00007fffeaaf3377 in ?? () from /usr/lib/libGLX_mesa.so.0
#7  0x00007fffeaafba7b in ?? () from /usr/lib/libGLX_mesa.so.0
#8  0x00007fffeaae7d09 in ?? () from /usr/lib/libGLX_mesa.so.0
#9  0x00007fffeaae3335 in ?? () from /usr/lib/libGLX_mesa.so.0
#10 0x00007fffeaae3d4d in ?? () from /usr/lib/libGLX_mesa.so.0
#11 0x00007ffff3321f5f in ?? () from /usr/lib/qt/plugins/xcbglintegrations/libqxcb-glx-integration.so
#12 0x00007ffff31de99a in QXcbWindow::create() () from /usr/lib/libQt5XcbQpa.so.5
#13 0x00007ffff31c9880 in QXcbIntegration::createPlatformWindow(QWindow*) const () from /usr/lib/libQt5XcbQpa.so.5
#14 0x00007ffff746a9d8 in QWindowPrivate::create(bool, unsigned long long) () from /usr/lib/libQt5Gui.so.5
#15 0x00007ffff7a888d8 in QWidgetPrivate::create_sys(unsigned long long, bool, bool) () from /usr/lib/libQt5Widgets.so.5
#16 0x00007ffff7a88f30 in QWidget::create(unsigned long long, bool, bool) () from /usr/lib/libQt5Widgets.so.5
#17 0x00007ffff7a96596 in QWidget::setVisible(bool) () from /usr/lib/libQt5Widgets.so.5
#18 0x0000555555555204 in main (argc=1, argv=0x7fffffffe578) at testqt.cpp:7

The commit message is nonsense. This problem has nothing to do with D-Bus. That's a red herring, because the QDBusConnection thread only exits after all open QDBusConnections close (including QDBusMessages holding them). The problem appears to be the XCB thread, stuck waiting for something, somehow, inside XCloseDisplay.

So truly no DBus in this case. It really seems to be a problem with the graphics library, which could be the reason why this problem does not seem to be common.


The patch is innocuous. I don't see *how* it can solve anything, though, because I don;'t know what DrKonqu::cleanup does.

One of the things that DrKonqi::cleanup() does is sending SIGCONT to the debuggee to finish it. I just checked: Not sending the signal makes DrKonqi quit entirely.
I will add a comment in the code and change the commit message. The patch still remains a workaround though.

This last backtrace does not show anything stuck. Thread 1 was actively running, in fact (it's inside of malloc).

Also note your testcase has no window, since the widget is destroyed before app.exec().

This last backtrace does not show anything stuck. Thread 1 was actively running, in fact (it's inside of malloc).

Also note your testcase has no window, since the widget is destroyed before app.exec().

But it actually is stuck. That's the backtrace after CTRL+C in gdb of the stuck example and sending SIGSTOP to KDevelop.

A backtrace where it gets stuck in the destructor of QApplication.

(gdb) info thread
  Id   Target Id                                          Frame 
* 1    Thread 0x7ffff36a2f80 (LWP 6015) "testqt"          0x00007ffff6906f6d in __pthread_timedjoin_ex () from /usr/lib/libpthread.so.0
  3    Thread 0x7fffe9642700 (LWP 6026) "testqt:disk$0"   0x00007ffff690bafc in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /usr/lib/libpthread.so.0
  4    Thread 0x7fffe8e41700 (LWP 6027) "QDBusConnection" 0x00007ffff6a0fc21 in poll () from /usr/lib/libc.so.6
(gdb) thread apply all bt

Thread 4 (Thread 0x7fffe8e41700 (LWP 6027)):
#0  0x00007ffff6a0fc21 in poll () from /usr/lib/libc.so.6
#1  0x00007ffff5e81540 in ?? () from /usr/lib/libglib-2.0.so.0
#2  0x00007ffff5e8162e in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#3  0x00007ffff70e3ce9 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#4  0x00007ffff708cb2c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#5  0x00007ffff6ed0569 in QThread::exec() () from /usr/lib/libQt5Core.so.5
#6  0x00007ffff3108ba6 in ?? () from /usr/lib/libQt5DBus.so.5
#7  0x00007ffff6ed196c in ?? () from /usr/lib/libQt5Core.so.5
#8  0x00007ffff6905a9d in start_thread () from /usr/lib/libpthread.so.0
#9  0x00007ffff6a1ab23 in clone () from /usr/lib/libc.so.6

Thread 3 (Thread 0x7fffe9642700 (LWP 6026)):
#0  0x00007ffff690bafc in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007fffe9c5ec94 in ?? () from /usr/lib/dri/i965_dri.so
#2  0x00007fffe9c5e9b8 in ?? () from /usr/lib/dri/i965_dri.so
#3  0x00007ffff6905a9d in start_thread () from /usr/lib/libpthread.so.0
#4  0x00007ffff6a1ab23 in clone () from /usr/lib/libc.so.6

Thread 1 (Thread 0x7ffff36a2f80 (LWP 6015)):
#0  0x00007ffff6906f6d in __pthread_timedjoin_ex () from /usr/lib/libpthread.so.0
#1  0x00007fffe9c5ea71 in ?? () from /usr/lib/dri/i965_dri.so
#2  0x00007fffe9c5f309 in ?? () from /usr/lib/dri/i965_dri.so
#3  0x00007fffe9c5a73a in ?? () from /usr/lib/dri/i965_dri.so
#4  0x00007fffe9be4344 in ?? () from /usr/lib/dri/i965_dri.so
#5  0x00007fffe9c563cf in ?? () from /usr/lib/dri/i965_dri.so
#6  0x00007fffeaafb07c in ?? () from /usr/lib/libGLX_mesa.so.0
#7  0x00007fffeaae7822 in ?? () from /usr/lib/libGLX_mesa.so.0
#8  0x00007fffeaae78a9 in ?? () from /usr/lib/libGLX_mesa.so.0
#9  0x00007fffeaae79fe in ?? () from /usr/lib/libGLX_mesa.so.0
#10 0x00007ffff5cc03e2 in XCloseDisplay () from /usr/lib/libX11.so.6
#11 0x00007ffff31f1f52 in ?? () from /usr/lib/libQt5XcbQpa.so.5
#12 0x00007ffff31c711a in QXcbConnection::~QXcbConnection() () from /usr/lib/libQt5XcbQpa.so.5
#13 0x00007ffff31c83d7 in QXcbIntegration::~QXcbIntegration() () from /usr/lib/libQt5XcbQpa.so.5
#14 0x00007ffff31c84da in QXcbIntegration::~QXcbIntegration() () from /usr/lib/libQt5XcbQpa.so.5
#15 0x00007ffff7455ed9 in QGuiApplicationPrivate::~QGuiApplicationPrivate() () from /usr/lib/libQt5Gui.so.5
#16 0x00007ffff7a546fa in QApplicationPrivate::~QApplicationPrivate() () from /usr/lib/libQt5Widgets.so.5
#17 0x00007ffff70bf86f in QObject::~QObject() () from /usr/lib/libQt5Core.so.5
#18 0x00007ffff70902b0 in QCoreApplication::~QCoreApplication() () from /usr/lib/libQt5Core.so.5
#19 0x00007ffff7a56842 in QApplication::~QApplication() () from /usr/lib/libQt5Widgets.so.5
#20 0x0000555555555221 in main (argc=1, argv=0x7fffffffe578) at testqt.cpp:6

I repeat: there's no indication in the backtrace that it is stuck. What's your evidence that it is? You wrote an application that shows nothing and never exits. Now it showed nothing and didn't exit. That's not stuck, that's the expected behaviour.

This new backtrace *is* a stuck application. Please report the issue to Mesa (dri/i965). Cc me, I can walk three paces in the office to the Mesa devs and help them figure out what's happening.

Mesa debug symbols would be helpful.

Anyway, as a workaround for the issue, this change seems acceptable.

croick updated this revision to Diff 52524.Feb 25 2019, 12:09 PM
croick retitled this revision from [DrKonqi] Create QApplication in a scope to fix possible deadlock to Create QApplication in a scope to work around possible deadlock.
croick edited the summary of this revision. (Show Details)
  • add comment

I repeat: there's no indication in the backtrace that it is stuck. What's your evidence that it is? You wrote an application that shows nothing and never exits. Now it showed nothing and didn't exit. That's not stuck, that's the expected behaviour.

It normally does exit, I never call app.exec(). It does not exit if we have the deadlock situation between KDevelop and DrKonqi however. But it doesn't matter, I found glxgears is a better example for https://bugs.freedesktop.org/show_bug.cgi?id=109777.

croick updated this revision to Diff 59395.Jun 8 2019, 11:55 AM

Rebase to current master

croick abandoned this revision.Jul 9 2019, 9:18 PM

I can no longer reproduce the deadlock, so I'll abandon this.