Bug 358787 - deadlock between background parser and code completion
Summary: deadlock between background parser and code completion
Status: REOPENED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (Clang-based) (show other bugs)
Version: git master
Platform: Other Linux
: VHI grave
Target Milestone: 5.0.0
Assignee: kdevelop-bugs-null
URL:
Keywords: release_blocker, triaged
Depends on:
Blocks:
 
Reported: 2016-01-30 17:51 UTC by Milian Wolff
Modified: 2022-12-16 08:43 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Milian Wolff 2016-01-30 17:51:20 UTC
Ouch, this is going to be nasty... The background parser is stuck and code completion also isn't showing up anymore:


Thread 22 (Thread 0x7f81e8b5e700 (LWP 24145)):
#0  0x00007f8200ec518d in poll () from /usr/lib/libc.so.6
#1  0x00007f81f50f3ae2 in ?? () from /usr/lib/libxcb.so.1
#2  0x00007f81f50f5757 in xcb_wait_for_event () from /usr/lib/libxcb.so.1
#3  0x00007f81e9c4f379 in ?? () from /usr/lib/libQt5XcbQpa.so.5
#4  0x00007f8201ac4b8e in ?? () from /usr/lib/libQt5Core.so.5
#5  0x00007f81f9e184a4 in start_thread () from /usr/lib/libpthread.so.0
#6  0x00007f8200ece13d in clone () from /usr/lib/libc.so.6

Thread 21 (Thread 0x7f81d7544700 (LWP 24156)):
#0  0x00007f81f9e1e07f in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007f8201ac5e2b in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/libQt5Core.so.5
#2  0x00007f8201abdee6 in QReadWriteLock::lockForWrite() () from /usr/lib/libQt5Core.so.5
#3  0x00007f81fee3d6b7 in KDevelop::DUChainPrivate::doMoreCleanup (this=0x7f81ff6e4518 <KDevelop::(anonymous namespace)::Q_QGS_sdDUChainPrivate::innerFunction()::holder>, retries=1, needLockRepository=true) at /home/milian/projects/kf5/src/extragear/kdevelop/kdevplatform/language/duchain/duchain.cpp:718
#4  0x00007f81fee4e3e6 in KDevelop::DUChainPrivate::CleanupThread::run (this=0x390f770) at /home/milian/projects/kf5/src/extragear/kdevelop/kdevplatform/language/duchain/duchain.cpp:289
#5  0x00007f8201ac4b8e in ?? () from /usr/lib/libQt5Core.so.5
#6  0x00007f81f9e184a4 in start_thread () from /usr/lib/libpthread.so.0
#7  0x00007f8200ece13d in clone () from /usr/lib/libc.so.6

Thread 20 (Thread 0x7f81d52cd700 (LWP 24160)):
#0  0x00007f8200ec518d in poll () from /usr/lib/libc.so.6
#1  0x00007f81f7b2efbc in ?? () from /usr/lib/libglib-2.0.so.0
#2  0x00007f81f7b2f0cc in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#3  0x00007f8201cfc54f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#4  0x00007f8201ca357a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#5  0x00007f8201abfbe4 in QThread::exec() () from /usr/lib/libQt5Core.so.5
#6  0x00007f8201ac4b8e in ?? () from /usr/lib/libQt5Core.so.5
#7  0x00007f81f9e184a4 in start_thread () from /usr/lib/libpthread.so.0
#8  0x00007f8200ece13d in clone () from /usr/lib/libc.so.6

Thread 19 (Thread 0x7f81c54e1700 (LWP 24169)):
#0  0x00007f8200ec518d in poll () from /usr/lib/libc.so.6
#1  0x00007f81f7b2efbc in ?? () from /usr/lib/libglib-2.0.so.0
#2  0x00007f81f7b2f0cc in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#3  0x00007f8201cfc56b in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#4  0x00007f8201ca357a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#5  0x00007f8201abfbe4 in QThread::exec() () from /usr/lib/libQt5Core.so.5
#6  0x00007f81fef909e4 in KDevelop::CompletionWorkerThread::run (this=0x4b86c60) at /home/milian/projects/kf5/src/extragear/kdevelop/kdevplatform/language/codecompletion/codecompletionmodel.cpp:89
#7  0x00007f8201ac4b8e in ?? () from /usr/lib/libQt5Core.so.5
#8  0x00007f81f9e184a4 in start_thread () from /usr/lib/libpthread.so.0
#9  0x00007f8200ece13d in clone () from /usr/lib/libc.so.6

Thread 18 (Thread 0x7f81b1ccb700 (LWP 24171)):
#0  0x00007f81f9e1970d in pthread_join () from /usr/lib/libpthread.so.0
#1  0x00007f81b26dfcd0 in llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned int) () from /usr/lib/../lib/libLLVM.so.3.7
#2  0x00007f81b2674af0 in llvm::CrashRecoveryContext::RunSafelyOnThread(llvm::function_ref<void ()>, unsigned int) () from /usr/lib/../lib/libLLVM.so.3.7
#3  0x00007f81b49f2e47 in ?? () from /usr/lib/libclang.so.3.7
#4  0x00007f81b4a0b253 in clang_codeCompleteAt () from /usr/lib/libclang.so.3.7
#5  0x00007f81b5970f8a in ClangCodeCompletionContext::ClangCodeCompletionContext (this=0x7f81acde6dd0, context=..., sessionData=..., url=..., position=..., text=..., followingText=...) at /home/milian/projects/kf5/src/extragear/kdevelop/kdevelop/languages/clang/codecompletion/context.cpp:767
#6  0x00007f81b596fdff in QSharedPointer<ClangCodeCompletionContext>::create<KDevelop::DUChainPointer<KDevelop::DUContext> const&, QExplicitlySharedDataPointer<ParseSessionData> const&, QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&> (arguments=..., arguments=..., arguments=..., arguments=..., arguments=..., arguments=...) at /usr/include/qt/QtCore/qsharedpointer_impl.h:400
#7  0x00007f81b596ed45 in (anonymous namespace)::ClangCodeCompletionWorker::qt_static_metacall (_o=0x7f81b1cca4e0, _c=32641, _id=-1311988400, _a=0x6ed8750) at /home/milian/projects/kf5/build/extragear/kdevelop/kdevelop/languages/clang/codecompletion/model.moc:85
#8  0x00007f81b596decc in (anonymous namespace)::ClangCodeCompletionWorker::completionRequested (this=0x54f65c0, url=..., position=..., text=..., followingText=...) at /home/milian/projects/kf5/src/extragear/kdevelop/kdevelop/languages/clang/codecompletion/model.cpp:114
#9  0x00007f81b596f230 in QtPrivate::FunctionPointer<void ((anonymous namespace)::ClangCodeCompletionWorker::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&)>::call<QtPrivate::List<QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&>, void> (f=(void ((anonymous namespace)::ClangCodeCompletionWorker::*)((anonymous namespace)::ClangCodeCompletionWorker * const, const QUrl &, const KTextEditor::Cursor &, const QString &, const QString &)) 0x7f81b596db80 <QObject::connect<void (ClangCodeCompletionModel::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&), void ((anonymous namespace)::ClangCodeCompletionWorker::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&)>(QtPrivate::FunctionPointer<void (ClangCodeCompletionModel::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&)>::Object const*, void (ClangCodeCompletionModel::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&), QtPrivate::FunctionPointer<void ((anonymous namespace)::ClangCodeCompletionWorker::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&)>::Object const*, void ((anonymous namespace)::ClangCodeCompletionWorker::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&), Qt::ConnectionType)+256>, o=0x54f65c0, arg=0xe830610) at /usr/include/qt/QtCore/qobjectdefs_impl.h:520
#10 0x00007f81b596f170 in QtPrivate::QSlotObject<void ((anonymous namespace)::ClangCodeCompletionWorker::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&), QtPrivate::List<QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&>, void>::impl (which=0, this_=0x7f81b596db80 <QObject::connect<void (ClangCodeCompletionModel::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&), void ((anonymous namespace)::ClangCodeCompletionWorker::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&)>(QtPrivate::FunctionPointer<void (ClangCodeCompletionModel::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&)>::Object const*, void (ClangCodeCompletionModel::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&), QtPrivate::FunctionPointer<void ((anonymous namespace)::ClangCodeCompletionWorker::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&)>::Object const*, void ((anonymous namespace)::ClangCodeCompletionWorker::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&), Qt::ConnectionType)+256>, r=0x0, a=0x7f81b596db80 <QObject::connect<void (ClangCodeCompletionModel::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&), void ((anonymous namespace)::ClangCodeCompletionWorker::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&)>(QtPrivate::FunctionPointer<void (ClangCodeCompletionModel::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&)>::Object const*, void (ClangCodeCompletionModel::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&), QtPrivate::FunctionPointer<void ((anonymous namespace)::ClangCodeCompletionWorker::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&)>::Object const*, void ((anonymous namespace)::ClangCodeCompletionWorker::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&), Qt::ConnectionType)+256>, ret=0x54f65c0) at /usr/include/qt/QtCore/qobject_impl.h:143
#11 0x00007f81b596f0a6 in QtPrivate::QSlotObject<void ((anonymous namespace)::ClangCodeCompletionWorker::*)(QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&), QtPrivate::List<QUrl const&, KTextEditor::Cursor const&, QString const&, QString const&>, void>::QSlotObject (this=0x54f65c0, f=NULL) at /usr/include/qt/QtCore/qobject_impl.h:152
#12 0x00007f8201cd51e1 in QObject::event(QEvent*) () from /usr/lib/libQt5Core.so.5
#13 0x00007f82025989ac in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#14 0x00007f820259de86 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#15 0x00007f8201ca5bab in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
#16 0x00007f8201ca7fa6 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/libQt5Core.so.5
#17 0x00007f8201cfc143 in ?? () from /usr/lib/libQt5Core.so.5
#18 0x00007f81f7b2edc7 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#19 0x00007f81f7b2f020 in ?? () from /usr/lib/libglib-2.0.so.0
#20 0x00007f81f7b2f0cc in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#21 0x00007f8201cfc54f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#22 0x00007f8201ca357a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#23 0x00007f8201abfbe4 in QThread::exec() () from /usr/lib/libQt5Core.so.5
#24 0x00007f81fef909e4 in KDevelop::CompletionWorkerThread::run (this=0x54f3e60) at /home/milian/projects/kf5/src/extragear/kdevelop/kdevplatform/language/codecompletion/codecompletionmodel.cpp:89
#25 0x00007f8201ac4b8e in ?? () from /usr/lib/libQt5Core.so.5
#26 0x00007f81f9e184a4 in start_thread () from /usr/lib/libpthread.so.0
#27 0x00007f8200ece13d in clone () from /usr/lib/libc.so.6

Thread 17 (Thread 0x7f81a9429700 (LWP 24202)):
#0  0x00007f8200ec518d in poll () from /usr/lib/libc.so.6
#1  0x00007f81f7b2efbc in ?? () from /usr/lib/libglib-2.0.so.0
#2  0x00007f81f7b2f0cc in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#3  0x00007f8201cfc54f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#4  0x00007f8201ca357a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#5  0x00007f8201abfbe4 in QThread::exec() () from /usr/lib/libQt5Core.so.5
#6  0x00007f82071c9055 in ?? () from /usr/lib/libQt5Qml.so.5
#7  0x00007f8201ac4b8e in ?? () from /usr/lib/libQt5Core.so.5
#8  0x00007f81f9e184a4 in start_thread () from /usr/lib/libpthread.so.0
#9  0x00007f8200ece13d in clone () from /usr/lib/libc.so.6

Thread 16 (Thread 0x7f819bfff700 (LWP 24432)):
#0  0x00007f81f9e1e07f in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007f8201ac5e2b in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/libQt5Core.so.5
#2  0x00007f8201abd2c7 in QReadWriteLock::lockForRead() () from /usr/lib/libQt5Core.so.5
#3  0x00007f81b58b44a4 in KTextEditor::operator>= (c1=..., c2=...) at /home/milian/projects/compiled/kf5/include/KF5/KTextEditor/ktexteditor/cursor.h:303
#4  0x00007f81b58b1b8d in ?? () at /usr/include/qt/QtCore/qlist.h:797 from /home/milian/projects/compiled/kf5/lib64/plugins/kdevplatform/24/kdevclangsupport.so
#5  0x00007f819bffe4b0 in ?? ()
#6  0x00007f819bffe8e8 in ?? ()
#7  0x00000000054f3530 in ?? ()
#8  0x00007f819bffe8e8 in ?? ()
#9  0x00007f819bffe900 in ?? ()
#10 0x00007f81b58af692 in (anonymous namespace)::trackerForUrl (url=...) at /home/milian/projects/kf5/src/extragear/kdevelop/kdevelop/languages/clang/clangparsejob.cpp:157
Backtrace stopped: frame did not save the PC

Thread 15 (Thread 0x7f81e24dc700 (LWP 24433)):
#0  0x00007f81f9e1e07f in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007f8201ac5e2b in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/libQt5Core.so.5
#2  0x00007f8201abd2c7 in QReadWriteLock::lockForRead() () from /usr/lib/libQt5Core.so.5
#3  0x00007f81b58b44a4 in KTextEditor::operator>= (c1=..., c2=...) at /home/milian/projects/compiled/kf5/include/KF5/KTextEditor/ktexteditor/cursor.h:303
#4  0x00007f81b58b1b8d in ?? () at /usr/include/qt/QtCore/qlist.h:797 from /home/milian/projects/compiled/kf5/lib64/plugins/kdevplatform/24/kdevclangsupport.so
#5  0x00007f81e24db4b0 in ?? ()
#6  0x00007f81e24db8e8 in ?? ()
#7  0x00000000054f3530 in ?? ()
#8  0x00007f81e24db8e8 in ?? ()
#9  0x00007f81e24db900 in ?? ()
#10 0x00007f81b58af692 in (anonymous namespace)::trackerForUrl (url=...) at /home/milian/projects/kf5/src/extragear/kdevelop/kdevelop/languages/clang/clangparsejob.cpp:157
Backtrace stopped: frame did not save the PC

Thread 14 (Thread 0x7f81aabc0700 (LWP 24434)):
#0  0x00007f81f9e1e07f in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007f8201ac5e2b in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/libQt5Core.so.5
#2  0x00007f8201abd2c7 in QReadWriteLock::lockForRead() () from /usr/lib/libQt5Core.so.5
#3  0x00007f81b58b44a4 in KTextEditor::operator>= (c1=..., c2=...) at /home/milian/projects/compiled/kf5/include/KF5/KTextEditor/ktexteditor/cursor.h:303
#4  0x00007f81b58b1b8d in ?? () at /usr/include/qt/QtCore/qlist.h:797 from /home/milian/projects/compiled/kf5/lib64/plugins/kdevplatform/24/kdevclangsupport.so
#5  0x00007f81aabbf4b0 in ?? ()
#6  0x00007f81aabbf8e8 in ?? ()
#7  0x00000000054f3530 in ?? ()
#8  0x00007f81aabbf8e8 in ?? ()
#9  0x00007f81aabbf900 in ?? ()
#10 0x00007f81b58af692 in (anonymous namespace)::trackerForUrl (url=...) at /home/milian/projects/kf5/src/extragear/kdevelop/kdevelop/languages/clang/clangparsejob.cpp:157
Backtrace stopped: frame did not save the PC

Thread 13 (Thread 0x7f81ab3c1700 (LWP 24435)):
#0  0x00007f8200ec9cf9 in syscall () from /usr/lib/libc.so.6
#1  0x00007f8201abcc58 in QBasicMutex::lockInternal() () from /usr/lib/libQt5Core.so.5
#2  0x00007f81b58c1c96 in ParseSession::ParseSession (this=0x7f81ab3c0810, data=...) at /home/milian/projects/kf5/src/extragear/kdevelop/kdevelop/languages/clang/duchain/parsesession.cpp:299
#3  0x00007f81b58afbde in ClangParseJob::run (this=0x6a28e10) at /home/milian/projects/kf5/src/extragear/kdevelop/kdevelop/languages/clang/clangparsejob.cpp:263
#4  0x00007f81b58b0bac in (anonymous namespace)::parsingEnvironmentFile (context=0x6a28e20) at /home/milian/projects/kf5/src/extragear/kdevelop/kdevelop/languages/clang/clangparsejob.cpp:152
#5  0x00007f81fe187b85 in ThreadWeaver::IdDecorator::run (this=0xa7d7a20, self=..., thread=0x7f819c1c7da0) at /home/milian/projects/kf5/src/frameworks/threadweaver/src/iddecorator.cpp:69
#6  0x00007f81fe188ae2 in ThreadWeaver::Executor::run (this=0x7f81fe3a5db8 <ThreadWeaver::Private::defaultExecutor>, job=..., thread=0x7f819c1c7da0) at /home/milian/projects/kf5/src/frameworks/threadweaver/src/executor.cpp:52
#7  0x00007f81fe187680 in ThreadWeaver::Private::DefaultExecutor::execute (this=0x7f81fe3a5db8 <ThreadWeaver::Private::defaultExecutor>, job=..., thread=0x7f819c1c7da0) at /home/milian/projects/kf5/src/frameworks/threadweaver/src/job_p.cpp:70
#8  0x00007f81fe188d8f in ThreadWeaver::ExecuteWrapper::executeWrapped (this=0xde64ff8, job=..., thread=0x7f819c1c7da0) at /home/milian/projects/kf5/src/frameworks/threadweaver/src/executewrapper.cpp:64
#9  0x00007f81fe1875cc in ThreadWeaver::Private::DebugExecuteWrapper::execute (this=0xde64ff8, job=..., th=0x7f819c1c7da0) at /home/milian/projects/kf5/src/frameworks/threadweaver/src/job_p.cpp:58
#10 0x00007f81fe188d8f in ThreadWeaver::ExecuteWrapper::executeWrapped (this=0xde65020, job=..., thread=0x7f819c1c7da0) at /home/milian/projects/kf5/src/frameworks/threadweaver/src/executewrapper.cpp:64
#11 0x00007f81fe188d15 in ThreadWeaver::ExecuteWrapper::execute (this=0xde65020, job=..., thread=0x7f819c1c7da0) at /home/milian/projects/kf5/src/frameworks/threadweaver/src/executewrapper.cpp:57
#12 0x00007f81fe188d8f in ThreadWeaver::ExecuteWrapper::executeWrapped (this=0xeb0c490, job=..., thread=0x7f819c1c7da0) at /home/milian/projects/kf5/src/frameworks/threadweaver/src/executewrapper.cpp:64
#13 0x00007f81fe188d15 in ThreadWeaver::ExecuteWrapper::execute (this=0xeb0c490, job=..., thread=0x7f819c1c7da0) at /home/milian/projects/kf5/src/frameworks/threadweaver/src/executewrapper.cpp:57
#14 0x00007f81fe185ce5 in ThreadWeaver::Job::execute (this=0x6a28e20, self=..., th=0x7f819c1c7da0) at /home/milian/projects/kf5/src/frameworks/threadweaver/src/job.cpp:83
#15 0x00007f81fe18b5d0 in ThreadWeaver::Collection::execute (this=0x6a28e20, job=..., thread=0x7f819c1c7da0) at /home/milian/projects/kf5/src/frameworks/threadweaver/src/collection.cpp:151
#16 0x00007f81fe188389 in ThreadWeaver::IdDecorator::execute (this=0xa7d7a20, self=..., thread=0x7f819c1c7da0) at /home/milian/projects/kf5/src/frameworks/threadweaver/src/iddecorator.cpp:177
#17 0x00007f81fe18530e in ThreadWeaver::Thread::run (this=0x7f819c1c7da0) at /home/milian/projects/kf5/src/frameworks/threadweaver/src/thread.cpp:114
#18 0x00007f8201ac4b8e in ?? () from /usr/lib/libQt5Core.so.5
#19 0x00007f81f9e184a4 in start_thread () from /usr/lib/libpthread.so.0
#20 0x00007f8200ece13d in clone () from /usr/lib/libc.so.6

Thread 12 (Thread 0x7f81a8c28700 (LWP 24436)):
#0  0x00007f81f9e1e07f in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007f8201ac5e2b in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/libQt5Core.so.5
#2  0x00007f8201abd2c7 in QReadWriteLock::lockForRead() () from /usr/lib/libQt5Core.so.5
#3  0x00007f81b58b44a4 in KTextEditor::operator>= (c1=..., c2=...) at /home/milian/projects/compiled/kf5/include/KF5/KTextEditor/ktexteditor/cursor.h:303
#4  0x00007f81b58b1b8d in ?? () at /usr/include/qt/QtCore/qlist.h:797 from /home/milian/projects/compiled/kf5/lib64/plugins/kdevplatform/24/kdevclangsupport.so
#5  0x00007f81a8c274b0 in ?? ()
#6  0x00007f81a8c278e8 in ?? ()
#7  0x00000000054f3530 in ?? ()
#8  0x00007f81a8c278e8 in ?? ()
#9  0x00007f81a8c27900 in ?? ()
#10 0x00007f81b58af692 in (anonymous namespace)::trackerForUrl (url=...) at /home/milian/projects/kf5/src/extragear/kdevelop/kdevelop/languages/clang/clangparsejob.cpp:157
Backtrace stopped: frame did not save the PC

Thread 11 (Thread 0x7f818f7fe700 (LWP 24440)):
#0  0x00007f8200ec518d in poll () from /usr/lib/libc.so.6
#1  0x00007f81f7b2efbc in ?? () from /usr/lib/libglib-2.0.so.0
#2  0x00007f81f7b2f0cc in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#3  0x00007f8201cfc56b in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#4  0x00007f8201ca357a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#5  0x00007f8201abfbe4 in QThread::exec() () from /usr/lib/libQt5Core.so.5
#6  0x00007f81fef909e4 in KDevelop::CompletionWorkerThread::run (this=0x1f60d50) at /home/milian/projects/kf5/src/extragear/kdevelop/kdevplatform/language/codecompletion/codecompletionmodel.cpp:89
#7  0x00007f8201ac4b8e in ?? () from /usr/lib/libQt5Core.so.5
#8  0x00007f81f9e184a4 in start_thread () from /usr/lib/libpthread.so.0
#9  0x00007f8200ece13d in clone () from /usr/lib/libc.so.6

Thread 10 (Thread 0x7f818d995700 (LWP 3989)):
#0  0x00007f81f9e1e07f in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007f81f9d03934 in ?? () from /usr/lib/libQt5Script.so.5
#2  0x00007f81f9d03979 in ?? () from /usr/lib/libQt5Script.so.5
#3  0x00007f81f9e184a4 in start_thread () from /usr/lib/libpthread.so.0
#4  0x00007f8200ece13d in clone () from /usr/lib/libc.so.6

Thread 9 (Thread 0x7f818ffff700 (LWP 4184)):
#0  0x00007f8200ec518d in poll () from /usr/lib/libc.so.6
#1  0x00007f81f7b2efbc in ?? () from /usr/lib/libglib-2.0.so.0
#2  0x00007f81f7b2f0cc in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#3  0x00007f8201cfc54f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#4  0x00007f8201ca357a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#5  0x00007f8201abfbe4 in QThread::exec() () from /usr/lib/libQt5Core.so.5
#6  0x00007f82071c9055 in ?? () from /usr/lib/libQt5Qml.so.5
#7  0x00007f8201ac4b8e in ?? () from /usr/lib/libQt5Core.so.5
#8  0x00007f81f9e184a4 in start_thread () from /usr/lib/libpthread.so.0
#9  0x00007f8200ece13d in clone () from /usr/lib/libc.so.6

Thread 8 (Thread 0x7f818e7fc700 (LWP 12833)):
#0  0x00007f81f9e1e07f in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007f81fc59548b in ?? () from /usr/lib/libQt5WebKit.so.5
#2  0x00007f81fc5954c9 in ?? () from /usr/lib/libQt5WebKit.so.5
#3  0x00007f81f9e184a4 in start_thread () from /usr/lib/libpthread.so.0
#4  0x00007f8200ece13d in clone () from /usr/lib/libc.so.6

Thread 7 (Thread 0x7f818effd700 (LWP 12834)):
#0  0x00007f8200ec518d in poll () from /usr/lib/libc.so.6
#1  0x00007f81f7b2efbc in ?? () from /usr/lib/libglib-2.0.so.0
#2  0x00007f81f7b2f0cc in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#3  0x00007f8201cfc54f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#4  0x00007f8201ca357a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#5  0x00007f8201abfbe4 in QThread::exec() () from /usr/lib/libQt5Core.so.5
#6  0x00007f8201ac4b8e in ?? () from /usr/lib/libQt5Core.so.5
#7  0x00007f81f9e184a4 in start_thread () from /usr/lib/libpthread.so.0
#8  0x00007f8200ece13d in clone () from /usr/lib/libc.so.6

Thread 6 (Thread 0x7f8177fff700 (LWP 12835)):
#0  0x00007f81f9e1e07f in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007f81fc294644 in ?? () from /usr/lib/libQt5WebKit.so.5
#2  0x00007f81fc5c5101 in ?? () from /usr/lib/libQt5WebKit.so.5
#3  0x00007f81f9e184a4 in start_thread () from /usr/lib/libpthread.so.0
#4  0x00007f8200ece13d in clone () from /usr/lib/libc.so.6

Thread 5 (Thread 0x7f8175106700 (LWP 12836)):
#0  0x00007f81f9e1e07f in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007f81fc2956b3 in ?? () from /usr/lib/libQt5WebKit.so.5
#2  0x00007f81fc5c5101 in ?? () from /usr/lib/libQt5WebKit.so.5
#3  0x00007f81f9e184a4 in start_thread () from /usr/lib/libpthread.so.0
#4  0x00007f8200ece13d in clone () from /usr/lib/libc.so.6

Thread 4 (Thread 0x7f8174905700 (LWP 12837)):
#0  0x00007f81f9e1e07f in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007f81fc2956b3 in ?? () from /usr/lib/libQt5WebKit.so.5
#2  0x00007f81fc5c5101 in ?? () from /usr/lib/libQt5WebKit.so.5
#3  0x00007f81f9e184a4 in start_thread () from /usr/lib/libpthread.so.0
#4  0x00007f8200ece13d in clone () from /usr/lib/libc.so.6

Thread 3 (Thread 0x7f8174104700 (LWP 12838)):
#0  0x00007f81f9e1e07f in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007f81fc2956b3 in ?? () from /usr/lib/libQt5WebKit.so.5
#2  0x00007f81fc5c5101 in ?? () from /usr/lib/libQt5WebKit.so.5
#3  0x00007f81f9e184a4 in start_thread () from /usr/lib/libpthread.so.0
#4  0x00007f8200ece13d in clone () from /usr/lib/libc.so.6

Thread 2 (Thread 0x7f8173903700 (LWP 13145)):
#0  0x00007f81b4f66b99 in ?? () from /usr/lib/libclang.so.3.7
#1  0x00007f81b4f6fb46 in ?? () from /usr/lib/libclang.so.3.7
#2  0x00007f81b4d2fe4e in ?? () from /usr/lib/libclang.so.3.7
#3  0x00007f81b4d30307 in ?? () from /usr/lib/libclang.so.3.7
#4  0x00007f81b4d4bd71 in ?? () from /usr/lib/libclang.so.3.7
#5  0x00007f81b4d4be98 in ?? () from /usr/lib/libclang.so.3.7
#6  0x00007f81b4d4caf4 in ?? () from /usr/lib/libclang.so.3.7
#7  0x00007f81b51e99ba in ?? () from /usr/lib/libclang.so.3.7
#8  0x00007f81b51e36bb in ?? () from /usr/lib/libclang.so.3.7
#9  0x00007f81b51e630d in ?? () from /usr/lib/libclang.so.3.7
#10 0x00007f81b51e639f in ?? () from /usr/lib/libclang.so.3.7
#11 0x00007f81b51e6419 in ?? () from /usr/lib/libclang.so.3.7
#12 0x00007f81b51eea66 in ?? () from /usr/lib/libclang.so.3.7
#13 0x00007f81b521fcc6 in ?? () from /usr/lib/libclang.so.3.7
#14 0x00007f81b5224cd3 in ?? () from /usr/lib/libclang.so.3.7
#15 0x00007f81b52212bb in ?? () from /usr/lib/libclang.so.3.7
#16 0x00007f81b522187b in ?? () from /usr/lib/libclang.so.3.7
#17 0x00007f81b522639e in ?? () from /usr/lib/libclang.so.3.7
#18 0x00007f81b5226a9e in ?? () from /usr/lib/libclang.so.3.7
#19 0x00007f81b5226ad2 in ?? () from /usr/lib/libclang.so.3.7
#20 0x00007f81b5221422 in ?? () from /usr/lib/libclang.so.3.7
#21 0x00007f81b522187b in ?? () from /usr/lib/libclang.so.3.7
#22 0x00007f81b522199a in ?? () from /usr/lib/libclang.so.3.7
#23 0x00007f81b522217c in ?? () from /usr/lib/libclang.so.3.7
#24 0x00007f81b52212eb in ?? () from /usr/lib/libclang.so.3.7
#25 0x00007f81b522187b in ?? () from /usr/lib/libclang.so.3.7
#26 0x00007f81b522639e in ?? () from /usr/lib/libclang.so.3.7
#27 0x00007f81b5228b26 in ?? () from /usr/lib/libclang.so.3.7
#28 0x00007f81b51afce2 in ?? () from /usr/lib/libclang.so.3.7
#29 0x00007f81b51c8f8d in ?? () from /usr/lib/libclang.so.3.7
#30 0x00007f81b51ac052 in ?? () from /usr/lib/libclang.so.3.7
#31 0x00007f81b51ac6c9 in ?? () from /usr/lib/libclang.so.3.7
#32 0x00007f81b51ac6ff in ?? () from /usr/lib/libclang.so.3.7
#33 0x00007f81b51b2e8f in ?? () from /usr/lib/libclang.so.3.7
#34 0x00007f81b51d8265 in ?? () from /usr/lib/libclang.so.3.7
#35 0x00007f81b51d8d3c in ?? () from /usr/lib/libclang.so.3.7
#36 0x00007f81b51cbd9d in ?? () from /usr/lib/libclang.so.3.7
#37 0x00007f81b51b2eb1 in ?? () from /usr/lib/libclang.so.3.7
#38 0x00007f81b51b3869 in ?? () from /usr/lib/libclang.so.3.7
#39 0x00007f81b51a7a53 in ?? () from /usr/lib/libclang.so.3.7
#40 0x00007f81b4c4f096 in ?? () from /usr/lib/libclang.so.3.7
#41 0x00007f81b4c17592 in ?? () from /usr/lib/libclang.so.3.7
#42 0x00007f81b4a0a9a2 in ?? () from /usr/lib/libclang.so.3.7
#43 0x00007f81b2674a2c in llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) () from /usr/lib/../lib/libLLVM.so.3.7
#44 0x00007f81b2674a84 in ?? () from /usr/lib/../lib/libLLVM.so.3.7
#45 0x00007f81b26dfc4d in ?? () from /usr/lib/../lib/libLLVM.so.3.7
#46 0x00007f81f9e184a4 in start_thread () from /usr/lib/libpthread.so.0
#47 0x00007f8200ece13d in clone () from /usr/lib/libc.so.6

Thread 1 (Thread 0x7f81ea044880 (LWP 24137)):
#0  0x00007f8200ec518d in poll () from /usr/lib/libc.so.6
#1  0x00007f81f7b2efbc in ?? () from /usr/lib/libglib-2.0.so.0
#2  0x00007f81f7b2f0cc in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#3  0x00007f8201cfc54f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#4  0x00007f8201ca357a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#5  0x00007f8201cab53c in QCoreApplication::exec() () from /usr/lib/libQt5Core.so.5
#6  0x000000000040e7f5 in main (argc=3, argv=0x7ffea3987fa8) at /home/milian/projects/kf5/src/extragear/kdevelop/kdevelop/app/main.cpp:655
quit
Detaching from program: /home/milian/projects/compiled/kf5/bin/kdevelop, process 24137


Reproducible: Couldn't Reproduce

Steps to Reproduce:
not sure how to reproduce it, first time I hit this

Actual Results:  
deadlock

Expected Results:  
no deadlock
Comment 1 Milian Wolff 2016-02-21 13:30:25 UTC
I reproduced it once more and I think the real issue above is that the clang thread (#2) is not joining into the code completion thread (#18). If that would happen, then the parse thread in #13 should be able to continue.

Am I missing something? Maybe this was not a real deadlock, just some odd behavior in clang that resulted in many seconds of parsetime? Without more debug symbols, this is hard to debug... I'll close this for now and reopen if I ever hit it again with more debug symbols in clang available.
Comment 2 Andrew Crouthamel 2018-09-25 21:48:43 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information as soon as possible and set the bug status as REPORTED. Due to regular bug tracker maintenance, if the bug is still in NEEDSINFO status with no change in 30 days, the bug will be closed as RESOLVED > WORKSFORME due to lack of needed information.

For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please set the bug status as REPORTED so that the KDE team knows that the bug is ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 3 Andrew Crouthamel 2018-10-27 02:31:00 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least 30 days. The bug is now closed as RESOLVED > WORKSFORME due to lack of needed information.

For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!
Comment 4 mswan 2019-06-22 00:30:18 UTC
This has occurred on my machine and it appears rather clear the culprit after having done some investigation. The following locking events should make it apparent:

ClangParseJob thread:
1. In ClangParseJob::run, ParseSession constructor is invoked which locks on the corresponding parse session.
2. ClangParseInfo::run then invokes ClangHelpers::buildDUChain which then invokes DUChainWriteLocker constructor.

ClangCodeCompletion thread:
1. In ClangCodeCompletionWorker::run, DUChainReadLocker constructor is invoked.
2. ClangCodeCompletionWorker::run then invokes createCompletionContext which invokes ClangCodeCompletionContext constructor which then invokes ParseSesssion constructor on the same parse session in ClangParseJob 1.

Consequently, ClangCodeCompletion thread could hold a readlock on DUChain while ClangParseJob could hold a lock on the parse session while they both need simultaneous access to both resources.
Comment 5 mswan 2019-06-22 00:30:35 UTC
See comment above, definitely still an issue.
Comment 6 mswan 2019-06-22 00:33:07 UTC
Hmm, on second thought, it seems that the DUChain read lock is unlocked before createCompletionContext is invoked. Perhaps my above analysis is not the case.
Comment 7 mswan 2019-06-24 17:59:40 UTC
Alright, now I believe I have actually figured this out for the deadlock I was seeing although I am not sure it is the same one reported in this ticket. I think Milian's suspicion of clang taking an exorbitant amount of time appears to be the source of his problem, having given his call stack some scrutiny. In my case however, I see a call stack in which AbstractNavigationWidgetPrivate::anchorClicked is invoked which holds onto a DUChain read lock and some 53 calls up the call stack later, we reach DUChainWriteLocker::lock. Even just looking at the next relevant function up the call stack in AdaptSignatureAction::execute, it should already be the case that our current thread does not hold a read lock on DUChain, but along this code path it necessarily does. This regression was added when resolving ticket #386901, and the issue there should have probably been addressed by moving the DUChaineReadLocker further up the stack and left the contract assumed by acceptLink to ensure there are no locks on DUChain and the callee will make use of such locks as needed.
Comment 8 Bug Janitor Service 2021-10-29 15:38:43 UTC
A possibly relevant merge request was started @ https://invent.kde.org/kdevelop/kdevelop/-/merge_requests/277
Comment 9 Igor Kushnir 2022-05-03 13:12:06 UTC
Git commit a947074f0872ad3245b8c73679143998a88e3753 by Igor Kushnir, on behalf of Jonathan L. Verner.
Committed on 01/05/2022 at 12:56.
Pushed by igorkushnir into branch 'release/22.04'.

Fix a crash in the "update signature action".

The problem seems to be that the DUChain is readlocked in
`AbstractNavigationWidgetPrivate::anchorClicked` (see also [2]),
which then proceeds through the following (backtrace-like) call chain

  #9  AdaptSignatureAction::execute()
      (at plugins/clang/codegen/adaptsignatureaction.cpp:83)
  #10 ProblemNavigationContext::executeAction(int)
(at kdevplatform/language/duchain/navigation
problemnavigationcontext.cpp:258)
  #11 ProblemNavigationContext::executeKeyAction(QString const&)
(at
kdevplatform/language/duchain/navigation/problemnavigationcontext.cpp:243)
const&)
(at
kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp:183)
  #13 AbstractNavigationContext::acceptLink(QString const&)
(at
kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp:487)
  #14 AbstractNavigationWidgetPrivate::anchorClicked

which ends at

  plugins/clang/codegen/adaptsignatureaction.cpp:83

with an `ENSURE_CHAIN_NOT_LOCKED` macro, which asserts.

However, the lock in `anchorClicked` was added there in
commit ff72bc32 to fix bug 386901 ([1]) so it cannot
just be removed. The callchain triggering the 386901 bug looks
as follows:

  #0 FunctionDefinition::declaration
     (at kdevplatform/language/duchain/functiondefinition.cpp:52)
  #1 FunctionDefinition::declaration
     (at kdevplatform/language/duchain/functiondefinition.cpp:52)
AbstractDeclarationNavigationContext::AbstractDeclarationNavigationContext
(at
kdevplatform/language/duchain/navigation/abstractdeclarationnavigationcontext.cpp:67)
  #3 DeclarationNavigationContext::AbstractDeclarationNavigationContext
     (at plugins/clang/duchain/navigationwidget.cpp:38)
  #4 ClangNavigationWidget::ClangNavigationWidget
     (at plugins/clang/duchain/navigationwidget.cpp:98)
  #5 ClangDUContext<KDevelop::TopDUContext, 140>::createNavigationWidget
     (at plugins/clang/duchain/clangducontext.cpp:46)
  #6 AbstractNavigationContext::registerChild
(at
kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp:281)
  #7 AbstractNavigationContext::execute
(at
kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp:201)
  #8 AbstractNavigationContext::acceptLink
(at
kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp:487)
  #9 AbstractNavigationWidgetPrivate::anchorClicked
(at
kdevplatform/language/duchain/navigation/abstractnavigationwidget.cpp:285)

which hits an assert at

   kdevplatform/language/duchain/functiondefinition.cpp:52

in the `ENSURE_CAN_READ` macro.

This commit moves the lock from `anchorClicked` into
`AbstractNavigationContext::registerChild`, which is the
last opportunity for a lock before a language-plugin specific
method is called (so that the bug does not reappear in
other language plugins).

References

[1] https://bugs.kde.org/show_bug.cgi?id=386901
[2] https://phabricator.kde.org/D22182
Related: bug 416714
FIXED-IN: 5.8.220401

M  +11   -0    kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp
M  +0    -2    kdevplatform/language/duchain/navigation/abstractnavigationwidget.cpp

https://invent.kde.org/kdevelop/kdevelop/commit/a947074f0872ad3245b8c73679143998a88e3753
Comment 10 Mahima Mantri 2022-12-16 08:43:53 UTC
Nice post. Thanks for sharing. 

Visit: https://www.sevenmentor.com