SUMMARY KDevelop, built against LLVM 17.0.6, always crashes when loading existing session cache. STEPS TO REPRODUCE 1. Load a project, wait for it to be parsed. 2. Close KDevelop. 3. Re-open KDevelop with this session, without clearing duchain cache or reparsing project on opening enabled. OBSERVED RESULT Thread 75 "Queue(0x555555d" received signal SIGSEGV, Segmentation fault. #0 0x00007ffff5d986fa in ??? () at /usr/lib64/libc.so.6 #1 0x00007ffff41552b3 in KDevelop::ItemRepository<KDevelop::(anonymous namespace)::PersistentSymbolTableItem, KDevelop::(anonymous namespace)::PersistentSymbolTableRequestItem, true, QRecursiveMutex, 0u, 1048576u>::convertMonsterBucket(int, int) [clone .isra.0] () at /usr/lib64/libKDevPlatformLanguage.so.514 #2 0x00007ffff41560b0 in KDevelop::ItemRepository<KDevelop::(anonymous namespace)::PersistentSymbolTableItem, KDevelop::(anonymous namespace)::PersistentSymbolTableRequestItem, true, QRecursiveMutex, 0u, 1048576u>::index(KDevelop::(anonymous namespace)::PersistentSymbolTableRequestItem const&) [clone .isra.0] () at /usr/lib64/libKDevPlatformLanguage.so.514 #3 0x00007ffff415721a in KDevelop::PersistentSymbolTable::addDeclaration(KDevelop::IndexedQualifiedIdentifier const&, KDevelop::IndexedDeclaration const&) () at /usr/lib64/libKDevPlatformLanguage.so.514 #4 0x00007ffff40f53b8 in KDevelop::Declaration::setInSymbolTable(bool) () at /usr/lib64/libKDevPlatformLanguage.so.514 #5 0x00007fffae913059 in KDevelop::Declaration* (anonymous namespace)::Visitor::createDeclarationCommon<(CXCursorKind)201, KDevelop::Declaration>(CXCursor, KDevelop::Identifier const&) () at /usr/lib64/libKDevClangPrivate.so.514 #6 0x00007fffae918402 in (anonymous namespace)::visitCursor(CXCursor, CXCursor, void*) () at /usr/lib64/libKDevClangPrivate.so.514 #7 0x00007fff952de24c in clang::cxcursor::CursorVisitor::Visit(CXCursor, bool) [clone .localalias] () at /usr/lib/llvm/17/lib64/libclang.so.17 #8 0x00007fff952deeee in clang::cxcursor::CursorVisitor::handleDeclForVisitation(clang::Decl const*) [clone .localalias] () at /usr/lib/llvm/17/lib64/libclang.so.17 #9 0x00007fff952defb8 in clang::cxcursor::CursorVisitor::VisitDeclContext(clang::DeclContext*) [clone .localalias] () at /usr/lib/llvm/17/lib64/libclang.so.17 #10 0x00007fff952ddf2e in clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) [clone .localalias] () at /usr/lib/llvm/17/lib64/libclang.so.17 #11 0x00007fff952de10a in clang_visitChildren () at /usr/lib/llvm/17/lib64/libclang.so.17 #12 0x00007fffae9092a3 in Builder::visit(CXTranslationUnitImpl*, void*, QHash<void*, KDevelop::ReferencedTopDUContext> const&, bool) () at /usr/lib64/libKDevClangPrivate.so.514 #13 0x00007fffae923516 in ClangHelpers::buildDUChain(void*, QMultiHash<void*, Import> const&, ParseSession const&, QFlags<KDevelop::TopDUContext::Feature>, QHash<void*, KDevelop::ReferencedTopDUContext>&, QHash<KDevelop::IndexedString, KDevelop::ModificationRevision> const&, KDevelop::IndexedString const&, ClangIndex*, std::function<bool ()> const&) () at /usr/lib64/libKDevClangPrivate.so.514 #14 0x00007fffae922d22 in ClangHelpers::buildDUChain(void*, QMultiHash<void*, Import> const&, ParseSession const&, QFlags<KDevelop::TopDUContext::Feature>, QHash<void*, KDevelop::ReferencedTopDUContext>&, QHash<KDevelop::IndexedString, KDevelop::ModificationRevision> const&, KDevelop::IndexedString const&, ClangIndex*, std::function<bool ()> const&) () at /usr/lib64/libKDevClangPrivate.so.514 #15 0x00007fffae922d22 in ClangHelpers::buildDUChain(void*, QMultiHash<void*, Import> const&, ParseSession const&, QFlags<KDevelop::TopDUContext::Feature>, QHash<void*, KDevelop::ReferencedTopDUContext>&, QHash<KDevelop::IndexedString, KDevelop::ModificationRevision> const&, KDevelop::IndexedString const&, ClangIndex*, std::function<bool ()> const&) () at /usr/lib64/libKDevClangPrivate.so.514 #16 0x00007fffae922d22 in ClangHelpers::buildDUChain(void*, QMultiHash<void*, Import> const&, ParseSession const&, QFlags<KDevelop::TopDUContext::Feature>, QHash<void*, KDevelop::ReferencedTopDUContext>&, QHash<KDevelop::IndexedString, KDevelop::ModificationRevision> const&, KDevelop::IndexedString const&, ClangIndex*, std::function<bool ()> const&) () at /usr/lib64/libKDevClangPrivate.so.514 #17 0x00007fffae922d22 in ClangHelpers::buildDUChain(void*, QMultiHash<void*, Import> const&, ParseSession const&, QFlags<KDevelop::TopDUContext::Feature>, QHash<void*, KDevelop::ReferencedTopDUContext>&, QHash<KDevelop::IndexedString, KDevelop::ModificationRevision> const&, KDevelop::IndexedString const&, ClangIndex*, std::function<bool ()> const&) () at /usr/lib64/libKDevClangPrivate.so.514 #18 0x00007fffae922d22 in ClangHelpers::buildDUChain(void*, QMultiHash<void*, Import> const&, ParseSession const&, QFlags<KDevelop::TopDUContext::Feature>, QHash<void*, KDevelop::ReferencedTopDUContext>&, QHash<KDevelop::IndexedString, KDevelop::ModificationRevision> const&, KDevelop::IndexedString const&, ClangIndex*, std::function<bool ()> const&) () at /usr/lib64/libKDevClangPrivate.so.514 #19 0x00007fffafe1020d in ClangParseJob::run(QSharedPointer<ThreadWeaver::JobInterface>, ThreadWeaver::Thread*) () at /usr/lib64/qt5/plugins/kdevplatform/514/kdevclangsupport.so #20 0x00007ffff283f027 in ThreadWeaver::IdDecorator::run(QSharedPointer<ThreadWeaver::JobInterface>, ThreadWeaver::Thread*) () at /usr/lib64/libKF5ThreadWeaver.so.5 #21 0x00007ffff283ec78 in ThreadWeaver::Executor::run(QSharedPointer<ThreadWeaver::JobInterface> const&, ThreadWeaver::Thread*) () at /usr/lib64/libKF5ThreadWeaver.so.5 #22 0x00007ffff283fb1f in ThreadWeaver::Job::execute(QSharedPointer<ThreadWeaver::JobInterface> const&, ThreadWeaver::Thread*) () at /usr/lib64/libKF5ThreadWeaver.so.5 #23 0x00007ffff2844811 in ThreadWeaver::Thread::run() () at /usr/lib64/libKF5ThreadWeaver.so.5 #24 0x00007ffff62d9037 in QThreadPrivate::start(void*) () at /usr/lib64/libQt5Core.so.5 #25 0x00007ffff5cd645b in ??? () at /usr/lib64/libc.so.6 #26 0x00007ffff5d48018 in ??? () at /usr/lib64/libc.so.6 SOFTWARE/OS VERSIONS Operating System: Gentoo Linux 2.14 KDE Plasma Version: 5.27.10 KDE Frameworks Version: 5.114.0 Qt Version: 5.15.12 Kernel Version: 6.7.2-gentoo-r1 (64-bit)
*** Bug 504216 has been marked as a duplicate of this bug. ***
A backtrace with KDevelop, KF and Qt debug symbols is attached to the duplicate bug. I have encountered crashes with very similar backtraces multiple times, usually after a system update AND clearing the cache. Clearing the cache again usually gets rid of the crash. I suspected this crash to be a regression due to the porting to Qt 6. But it was reported here half a year before the porting was completed, so it must be something else. The backtrace in the duplicate bug report contains "libclang-15.so.15", so I guess this is not a libclang regression. But it does not look like a KDevelop regression either, because there were effectively no changes to PersistentSymbolTable between https://commits.kde.org/kdevelop/fec7895a45b18f1fe76e1a024668efccc22c39cc (2022-10-07) and https://commits.kde.org/kdevelop/f711c1832e1a0e0702da1750c8019dbd2e204b87 (2024-07-17) Eugene, does the crash happen often on your system? Did it first happen in 2024 when you reported this bug?
i know this probably isnt very helpful, but i want to say i've seen this crash before 2022. i just didnt have any ability to send good debug logs back then
(In reply to Ian H from comment #3) > i know this probably isnt very helpful, but i want to say i've seen this > crash before 2022. i just didnt have any ability to send good debug logs > back then Actually this comment is helpful. Thanks :) Searched for "PersistentSymbolTableItem" among resolved bugs too and found many similar backtraces: https://bugs.kde.org/buglist.cgi?bug_status=UNCONFIRMED&bug_status=CONFIRMED&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=RESOLVED&bug_status=NEEDSINFO&bug_status=VERIFIED&bug_status=CLOSED&list_id=3154395&longdesc=PersistentSymbolTableItem&longdesc_type=allwordssubstr&product=kdev-python&product=kdevelop&product=kdevplatform&query_format=advanced Perhaps the top of the backtraces has evolved due to code changes, but the following two consecutive calls are in just about every backtrace, even with old C++ support before libclang (!): PersistentSymbolTable::addDeclaration KDevelop::Declaration::setInSymbolTable I'll try to spot bugs in these two functions or perhaps in some other common parts of the many backtraces.
Analyzed the backtraces. My conclusion is that this bug is a direct successor to the infamous Bug 272408. The circumstances that lead to the crash and parts of the backtrace are similar. Before Milian's fix of Bug 272408, the crash occurred in ItemRepository::findIndex() or ItemRepository::deleteItem() called from PersistentSymbolTable::addDeclaration(): KDevelop::ItemRepository<KDevelop::PersistentSymbolTableItem, KDevelop::PersistentSymbolTableRequestItem, true, false, 0u, 1048576u>::findIndex KDevelop::PersistentSymbolTable::addDeclaration KDevelop::Declaration::setInSymbolTable OR KDevelop::ItemRepository<KDevelop::PersistentSymbolTableItem, KDevelop::PersistentSymbolTableRequestItem, true, false, 0u, 1048576u>::convertMonsterBucket(int, int) KDevelop::ItemRepository<KDevelop::PersistentSymbolTableItem, KDevelop::PersistentSymbolTableRequestItem, true, false, 0u, 1048576u>::deleteItem(unsigned int) KDevelop::PersistentSymbolTable::addDeclaration(KDevelop::IndexedQualifiedIdentifier const&, KDevelop::IndexedDeclaration const&) KDevelop::Declaration::setInSymbolTable(bool) And this new crash always occurs later - at the end of the lambda in PersistentSymbolTable::addDeclaration(), in ItemRepository::index() invoked from PersistentSymbolTable::addDeclaration(): KDevelop::ItemRepository<KDevelop::(anonymous namespace)::PersistentSymbolTableItem, KDevelop::(anonymous namespace)::PersistentSymbolTableRequestItem, true, QRecursiveMutex, 0u, 1048576u>::convertMonsterBucket(int, int) KDevelop::ItemRepository<KDevelop::(anonymous namespace)::PersistentSymbolTableItem, KDevelop::(anonymous namespace)::PersistentSymbolTableRequestItem, true, QRecursiveMutex, 0u, 1048576u>::index(KDevelop::(anonymous namespace)::PersistentSymbolTableRequestItem const&) operator() KDevelop::LockedItemRepository::write<KDevelop::PersistentSymbolTable, KDevelop::PersistentSymbolTable::addDeclaration(const KDevelop::IndexedQualifiedIdentifier&, const KDevelop::IndexedDeclaration&)::<lambda(KDevelop::(anonymous namespace)::PersistentSymbolTableRepo&)> > KDevelop::PersistentSymbolTable::addDeclaration KDevelop::Declaration::setInSymbolTable Unfortunately, I don't have a good enough understanding of the item repository to figure out what is still wrong there.