KGlobalAccel: Fix deadlock on exit under Windows
ClosedPublic

Authored by kfunk on Jul 12 2016, 8:25 AM.

Details

Summary

KDE applications dead-lock on exit without this patch. Need to free all
DBus resources before qApp exits.

Stack trace:

ntdll.dll!NtWaitForSingleObject()  Unknown
KernelBase.dll!WaitForSingleObjectEx() Unknown
Qt5Core.dll!QWaitCondition::wait(QMutex * mutex=0x000001e2ae2edbf0, unsigned long time=4294967295) Line 178 C++
Qt5Core.dll!QSemaphore::acquire(int n=1) Line 136   C++
Qt5Core.dll!QMetaObject::activate(QObject * sender=0x000001e2a7809450, int signalOffset, int local_signal_index, void * * argv=0x00000031c07af0d0) Line 3699    C++
Qt5Core.dll!QObject::~QObject() Line 913    C++
KF5GlobalAccel.dll!00007fff3101a115()   Unknown
Qt5Core.dll!QObjectPrivate::deleteChildren() Line 1960  C++
Qt5Core.dll!QObject::~QObject() Line 1034   C++
KF5GlobalAccel.dll!00007fff31036670()   Unknown
ucrtbase.dll!_time64() Unknown
ucrtbase.dll!__crt_seh_guarded_call<int>::operator()<class <lambda_e24bbb7b643b32fcea6fa61b31d4c984>,class <lambda_275893d493268fdec8709772e3fcec0e> &,class <lambda_9d71df4d7cf3f480f8d633942495c3b0> >(class <lambda_e24bbb7b643b32fcea6fa61b31d4c984> &&,class <lambda_275893d493268fdec8709772e3fcec0e> &,class <lambda_9d71df4d7cf3f480f8d633942495c3b0> &&)   Unknown
ucrtbase.dll!_execute_onexit_table()   Unknown
KF5GlobalAccel.dll!00007fff3102df62()   Unknown
KF5GlobalAccel.dll!00007fff3102e09e()   Unknown
ntdll.dll!LdrpCallInitRoutine() Unknown
ntdll.dll!LdrShutdownProcess()  Unknown
ntdll.dll!RtlExitUserProcess()  Unknown
kernel32.dll!ExitProcessImplementation()   Unknown
ucrtbase.dll!swprintf()    Unknown
ucrtbase.dll!swprintf()    Unknown
kdevelop.exe!__scrt_common_main_seh() Line 266  C++
kernel32.dll!BaseThreadInitThunk() Unknown
ntdll.dll!RtlUserThreadStart()  Unknown

Similar patch: https://phabricator.kde.org/D1909

Diff Detail

Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
kfunk updated this revision to Diff 5091.Jul 12 2016, 8:25 AM
kfunk retitled this revision from to KGlobalAccel: Fix deadlock on exit under Windows.
kfunk updated this object.
kfunk edited the test plan for this revision. (Show Details)
kfunk added a subscriber: Frameworks.
graesslin accepted this revision.Jul 12 2016, 8:47 AM
graesslin added a reviewer: graesslin.
graesslin added a subscriber: graesslin.

nice one.

This revision is now accepted and ready to land.Jul 12 2016, 8:47 AM
kfunk added a comment.Jul 12 2016, 8:59 AM

Waiting for a +1 from David.

There's one possible point of regression, namely if KGlobalAccel::self() is being used after qApp ran all the post routines (and KGlobalAccelPrivate::cleanup() has been invoked already). Not sure if this is a problem, though.

kfunk added a comment.Jul 12 2016, 9:02 AM

FYI: There are more issues in other frameworks, the next deadlock is in kiconthemes...

dfaure accepted this revision.Jul 12 2016, 6:57 PM
dfaure edited edge metadata.

Looks good to me. I don't think we have the need to use the singleton from other global destructors.

kfunk closed this revision.Jul 12 2016, 7:33 PM

Pushed.

commit 2bdb684a872aff26c01f5e1fc175fbaf663ad8ba
Author: Kevin Funk <kfunk@kde.org>
Date: Tue Jul 12 10:18:40 2016 +0200