[PATCH] wait for CompletionWorkerThread to exit before destroying it

Peter Oberndorfer kumbayo84 at arcor.de
Sun Dec 21 10:49:17 UTC 2008


otherwise we get "QThread: Destroyed while thread is still running"
warnings and crashes.
---
I think QThread::quit/exit only tells the event loop to exit
but it does not wait until the thread terminates.

Attached is a trace of a crash that is probably caused by this.

 language/codecompletion/codecompletionmodel.cpp |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 3a8ff8dbd9307d4a0757f5871a7be75971a0dd84.diff
Type: text/x-patch
Size: 441 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20081221/a60ea03e/attachment.diff>
-------------- next part --------------
kdevelop(17485)/kdevplatform (shell) KDevelop::UiController::removeToolView:
kdevelop(17485)/kdevplatform (sublime) Sublime::Area::removeToolView: Sublime::Area(0x6da80d8, name = "code") removed tool view  "org.kdevelop.DocumentsView"
kdevelop(17485)/kdevplatform (sublime) Sublime::Area::removeToolView: Sublime::Area(0x716cb88, name = "code") removed tool view  "org.kdevelop.DocumentsView"
kdevelop(17485)/kdevelop (cpp support) UIBlockTester::lockup: ui is blocking
kdevelop(17485)/kdevplatform (shell) KDevelop::UiController::removeToolView:
kdevelop(17485)/kdevplatform (sublime) Sublime::Area::removeToolView: Sublime::Area(0x6da80d8, name = "code") removed tool view  "org.kdevelop.ContextBrowser"
kdevelop(17485)/kdevplatform (sublime) Sublime::Area::removeToolView: Sublime::Area(0x716cb88, name = "code") removed tool view  "org.kdevelop.ContextBrowser"
QThread: Destroyed while thread is still running
kdevelop(17485)/kdevplatform (shell) KDevelop::UiController::removeToolView:
==17485==
==17485== Thread 3:
==17485== Invalid read of size 4
==17485==    at 0x588548D: QThreadPrivate::finish(void*) (qthread.h:131)
==17485==    by 0x5884FEF: QThreadPrivate::start(void*) (pthread.h:530)
==17485==    by 0x5A8B023: start_thread (in /lib/libpthread-2.6.1.so)
==17485==    by 0x5C671FD: clone (in /lib/libc-2.6.1.so)
==17485==  Address 0xa8a44c4 is 4 bytes inside a block of size 16 free'd
==17485==    at 0x40225AC: operator delete(void*) (vg_replace_malloc.c:342)
==17485==    by 0x608DE23: KDevelop::CompletionWorkerThread::~CompletionWorkerThread() (codecompletionmodel.cpp:64)
==17485==    by 0x608CA8B: KDevelop::CodeCompletionModel::~CodeCompletionModel() (codecompletionmodel.cpp:102)
==17485==    by 0xBD39FB7: CppCodeCompletionModel::~CppCodeCompletionModel() (cppcodecompletionmodel.cpp:79)
==17485==    by 0x598D29B: QObjectPrivate::deleteChildren() (qobject.cpp:1881)
==17485==    by 0x5995618: QObject::~QObject() (qobject.cpp:890)
==17485==    by 0x608A8E9: KDevelop::CodeCompletion::~CodeCompletion() (codecompletion.cpp:54)
==17485==    by 0x598D29B: QObjectPrivate::deleteChildren() (qobject.cpp:1881)
==17485==    by 0x5995618: QObject::~QObject() (qobject.cpp:890)
==17485==    by 0x4291A9C: KDevelop::IPlugin::~IPlugin() (iplugin.cpp:143)
==17485==    by 0xBD104C1: CppLanguageSupport::~CppLanguageSupport() (cpplanguagesupport.cpp:438)
==17485==    by 0x42CA66C: KDevelop::PluginController::unloadPlugin(KDevelop::IPlugin*, KDevelop::PluginController::PluginDeletion) (plugincontroller.cpp:289)
==17485==    by 0x42D14B1: KDevelop::PluginController::cleanup() (plugincontroller.cpp:188)
==17485==    by 0x42D4AA4: KDevelop::Core::cleanup() (core.cpp:198)
==17485==    by 0x42C3B91: KDevelop::MainWindow::~MainWindow() (mainwindow.cpp:88)
==17485==    by 0x598A9E1: qDeleteInEventHandler(QObject*) (qobject.cpp:3656)
==17485==    by 0x598CC5F: QObject::event(QEvent*) (qobject.cpp:1136)
==17485==    by 0x5097401: QWidget::event(QEvent*) (qwidget.cpp:7557)
==17485==    by 0x541495D: QMainWindow::event(QEvent*) (qmainwindow.cpp:1274)
==17485==    by 0x4D9DD5E: KMainWindow::event(QEvent*) (kmainwindow.cpp:1081)
==17485==    by 0x4DE28CB: KXmlGuiWindow::event(QEvent*) (kxmlguiwindow.cpp:131)
==17485==    by 0x503EBF7: QApplicationPrivate::notify_helper(QObject*, QEvent*) (qapplication.cpp:3809)
==17485==    by 0x5042D71: QApplication::notify(QObject*, QEvent*) (qapplication.cpp:3774)
==17485==    by 0x4CABF69: KApplication::notify(QObject*, QEvent*) (kapplication.cpp:307)
==17485==    by 0x597B4D0: QCoreApplication::notifyInternal(QObject*, QEvent*) (qcoreapplication.cpp:593)
==17485==    by 0x597C77E: QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (qcoreapplication.h:215)
==17485==    by 0x59AA701: QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (qeventdispatcher_unix.cpp:867)
==17485==    by 0x50D106C: QEventDispatcherX11::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (qeventdispatcher_x11.cpp:154)
==17485==    by 0x597A830: QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (qeventloop.cpp:149)
==17485==    by 0x597A9A8: QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (qeventloop.cpp:200)
==17485==
==17485== Invalid read of size 4
==17485==    at 0x587F60D: QMutex::lock() (qmutex.cpp:153)
==17485==    by 0x588558F: QThreadPrivate::finish(void*) (qmutex.h:122)
==17485==    by 0x5884FEF: QThreadPrivate::start(void*) (pthread.h:530)
==17485==    by 0x5A8B023: start_thread (in /lib/libpthread-2.6.1.so)
==17485==    by 0x5C671FD: clone (in /lib/libc-2.6.1.so)
==17485==  Address 0x44 is not stack'd, malloc'd or (recently) free'd
KCrash: crashing... crashRecursionCounter = 2


More information about the KDevelop-devel mailing list