DUChain: Fix frequent crash on exit

Authored by kfunk on Feb 10 2016, 5:17 PM.

Description

DUChain: Fix frequent crash on exit

Fix: Don't emit signals in DUChain::emitUpdateReady +
DUChain::emitDeclarationSelected if the DUChain is dead already

Detected by ASAN

Trace:

30614==ERROR: AddressSanitizer: heap-use-after-free on address

0x6040004a6098 at pc 0x7f5fdbe99d34 bp 0x7ffcd17b7f70 sp 0x7ffcd17b7f68
READ of size 8 at 0x6040004a6098 thread T0

#0 0x7f5fdbe99d33 in KDevelop::TopDUContext::d_func() const

/home/kfunk/devel/src/kf5/kdevplatform-stable/language/duchain/topducontext.h:337:226

#1 0x7f5fdbe99d33 in KDevelop::TopDUContext::problems() const

/home/kfunk/devel/src/kf5/kdevplatform-stable/language/duchain/topducontext.cpp:926

#2 0x7f5fdbd3ce69 in

KDevelop::StaticAssistantsManager::Private::checkAssistantForProblems(KDevelop::TopDUContext*)
/home/kfunk/devel/src/kf5/kdevplatform-stable/language/assistant/staticassistantsmanager.cpp:288:112

#3 0x7f5fdbd3ccdc in

KDevelop::StaticAssistantsManager::Private::updateReady(KDevelop::IndexedString
const&, KDevelop::ReferencedTopDUContext const&)
/home/kfunk/devel/src/kf5/kdevplatform-stable/language/assistant/staticassistantsmanager.cpp:251:9
...

0x6040004a6098 is located 8 bytes inside of 48-byte region
[0x6040004a6090,0x6040004a60c0)
freed by thread T0 here:

#0 0x4e43a2 in operator delete(void*)

(/home/kfunk/devel/install/kf5-stable/bin/kdevelop+0x4e43a2)

#1 0x7f5fb64a1bf5 in ClangDUContext<KDevelop::TopDUContext,

140>::~ClangDUContext()
/home/kfunk/devel/src/kf5/kdevelop-stable/languages/clang/duchain/clangducontext.h:29:7

#2 0x7f5fdbe9891f in KDevelop::TopDUContext::deleteSelf()

/home/kfunk/devel/src/kf5/kdevplatform-stable/language/duchain/topducontext.cpp:580:3

#3 0x7f5fdbde6624 in

KDevelop::DUChainPrivate::removeDocumentChainFromMemory(KDevelop::TopDUContext*)
/home/kfunk/devel/src/kf5/kdevplatform-stable/language/duchain/duchain.cpp:407:5

#4 0x7f5fdbdf1d13 in KDevelop::DUChainPrivate::clear()

/home/kfunk/devel/src/kf5/kdevplatform-stable/language/duchain/duchain.cpp:370:7
...

> TopDUContext accessed after DUChain shutdown

Details

Committed
kfunkFeb 11 2016, 4:00 PM
Parents
R33:1bde953a690e: EnvironmentWidget: Fix issues wrt batch edit mode
Branches
Unknown
Tags
Unknown