[Kde-hardware-devel] Review Request: resolve deadlock on app exit in fstab backend

Aaron Seigo aseigo at kde.org
Tue Aug 31 21:25:13 CEST 2010



> On 2010-08-31 09:27:36, Mario Bensi wrote:
> > sorry about this problem.
> > The problem here, it's the QFileSystemWatcher must be deleted before Q[Core]Application, your solution is good but i think the QFileSystemWatcher is leaked when you detach this from the parent. I send another patch which complete your solution.
> > Thanks for your help.
> 
> Mario Bensi wrote:
>     fix commited revision 1170242

"but i think the QFileSystemWatcher is leaked when you detach this from the parent."

it's on application exit, so the process will terminate shortly. the OS cleans up at that point, so there is no leak. the reason i took the orphaning approach is that any such activity at application exit may end up (now or in the future) being undefined and lead to a repeat of the same or similar type of bug; by simply letting the kernel clean up once the process has terminated, there is less possibility of regression in future due to changes in the internal implementations of QCoreApplication and/or QThread infrastructure. in any case, thanks for committing (though i could have done that as well after you marked it with "ship it" :), i'll close this review request now.


- Aaron


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://reviewboard.kde.org/r/5193/#review7309
-----------------------------------------------------------


On 2010-08-31 01:09:50, Aaron Seigo wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://reviewboard.kde.org/r/5193/
> -----------------------------------------------------------
> 
> (Updated 2010-08-31 01:09:50)
> 
> 
> Review request for Solid.
> 
> 
> Summary
> -------
> 
> we're seeing this hang on Solid-using apps on application exit:
> 
> #0  0xffffe424 in __kernel_vsyscall ()
> #1  0xb5e9b125 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
> #2  0xb5f28f69 in QWaitConditionPrivate::wait (this=0x84116d8, time=4294967295)
>     at /home/aseigo/kde4/qt/src/corelib/thread/qwaitcondition_unix.cpp:88
> #3  0xb5f28d6d in QWaitCondition::wait (this=0x8428190, mutex=0x8428178, time=4294967295)
>     at /home/aseigo/kde4/qt/src/corelib/thread/qwaitcondition_unix.cpp:160
> #4  0xb5f2864e in QThread::wait (this=0x83bfac8, time=4294967295)
>     at /home/aseigo/kde4/qt/src/corelib/thread/qthread_unix.cpp:660
> #5  0xb6004859 in QFileSystemWatcher::~QFileSystemWatcher (this=0x8411200, 
>     __in_chrg=<value optimized out>) at /home/aseigo/kde4/qt/src/corelib/io/qfilesystemwatcher.cpp:440
> #6  0xb60049ad in QFileSystemWatcher::~QFileSystemWatcher (this=0x8411200, 
>     __in_chrg=<value optimized out>) at /home/aseigo/kde4/qt/src/corelib/io/qfilesystemwatcher.cpp:456
> #7  0xb6049478 in QObjectPrivate::deleteChildren (this=0x83c0d70)
>     at /home/aseigo/kde4/qt/src/corelib/kernel/qobject.cpp:1949
> #8  0xb6047d44 in QObject::~QObject (this=0x83c1618, __in_chrg=<value optimized out>)
>     at /home/aseigo/kde4/qt/src/corelib/kernel/qobject.cpp:945
> #9  0xb4e883ea in Solid::Ifaces::DeviceManager::~DeviceManager (this=0x83c1618, 
>     __in_chrg=<value optimized out>)
>     at /home/aseigo/kde4/KDE/kdelibs/solid/solid/ifaces/devicemanager.cpp:29
> #10 0xb4ece7a1 in Solid::Backends::Fstab::FstabManager::~FstabManager (this=0x83c1618, 
>     __in_chrg=<value optimized out>)
>     at /home/aseigo/kde4/KDE/kdelibs/solid/solid/backends/fstab/fstabmanager.cpp:132
> #11 0xb4ece7db in Solid::Backends::Fstab::FstabManager::~FstabManager (this=0x83c1618, 
>     __in_chrg=<value optimized out>)
>     at /home/aseigo/kde4/KDE/kdelibs/solid/solid/backends/fstab/fstabmanager.cpp:134
> #12 0xb4e70430 in qDeleteAll<QList<QObject*>::const_iterator> (begin=..., end=...)
>     at /home/aseigo/kde4/qt-copy/include/QtCore/qalgorithms.h:322
> #13 0xb4e702d9 in qDeleteAll<QList<QObject*> > (c=...)
>     at /home/aseigo/kde4/qt-copy/include/QtCore/qalgorithms.h:330
> #14 0xb4e6fe8d in Solid::ManagerBasePrivate::~ManagerBasePrivate (this=0x8416c58, 
>     __in_chrg=<value optimized out>) at /home/aseigo/kde4/KDE/kdelibs/solid/solid/managerbase.cpp:47
> #15 0xb4e72f72 in Solid::DeviceManagerPrivate::~DeviceManagerPrivate (this=0x8416c50, 
>     __in_chrg=<value optimized out>) at /home/aseigo/kde4/KDE/kdelibs/solid/solid/devicemanager.cpp:48
> #16 0xb4e72fc1 in Solid::DeviceManagerPrivate::~DeviceManagerPrivate (this=0x8416c50, 
>     __in_chrg=<value optimized out>) at /home/aseigo/kde4/KDE/kdelibs/solid/solid/devicemanager.cpp:62
> #17 0xb4e763f2 in QThreadStorage<Solid::DeviceManagerPrivate*>::deleteData (x=0x8416c50)
>     at /home/aseigo/kde4/qt-copy/include/QtCore/qthreadstorage.h:133
> #18 0xb5f26466 in QThreadStorageData::finish (p=0x80528d8)
>     at /home/aseigo/kde4/qt/src/corelib/thread/qthreadstorage.cpp:185
> #19 0xb6030be6 in QCoreApplicationPrivate::~QCoreApplicationPrivate (this=0x8079940, 
>     __in_chrg=<value optimized out>)
>     at /home/aseigo/kde4/qt/src/corelib/kernel/qcoreapplication.cpp:291
> #20 0xb53a446b in QApplicationPrivate::~QApplicationPrivate (this=0x8079940, 
> 
> it's hanging in a call to QInotifyFileSystemWatcherEngine::wait(), which is actually a call to QThread::wait(). on my laptop, this results in the process not exiting fully, a spike in CPU usage that slowly (over the course of several minutes) comes down to ~1% of the CPU. the spike happens increasingly quickly, and the spin down takes increasingly long as it approaches 0, which is probably a clue. :) 
> 
> as can be seen in the backtrace, QThreadStorageData::finish is being called, which results in Solid being destroyed, which results in the QThread-based QFileSystemWatcherEngine going into a wait mode ... deadlock.
> 
> this patch, while certainly not "pretty", does the job.
> 
> 
> This addresses bug 249557.
>     https://bugs.kde.org/show_bug.cgi?id=249557
> 
> 
> Diffs
> -----
> 
>   /trunk/KDE/kdelibs/solid/solid/backends/fstab/fstabmanager.h 1170183 
>   /trunk/KDE/kdelibs/solid/solid/backends/fstab/fstabmanager.cpp 1170183 
> 
> Diff: http://reviewboard.kde.org/r/5193/diff
> 
> 
> Testing
> -------
> 
> run plasma-desktop, try kquitapp plasma-desktop and ensure it exits cleanly.
> 
> 
> Thanks,
> 
> Aaron
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/kde-hardware-devel/attachments/20100831/eed33cb6/attachment.htm 


More information about the Kde-hardware-devel mailing list