Bug 511678

Summary: KDevelop segfault in itemrepository.h
Product: [Applications] kdevelop Reporter: JATothrim <jarmo.tiitto>
Component: Language Support: CPP (Clang-based)Assignee: kdevelop-bugs-null
Status: RESOLVED DUPLICATE    
Severity: crash CC: igorkuo
Priority: NOR    
Version First Reported In: 6.3.250802   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description JATothrim 2025-11-05 15:14:03 UTC
SUMMARY
KDevelop often segfaults while parsing my C++ project.

STEPS TO REPRODUCE
1. I open the project and do some developing and eventually KDevelop segfaults.
2. The segfault happen again if I don't clear the cache on next launch of KDevelop.
3. C++17 mode is enabled in the project settings.

OBSERVED RESULT
Segfault

EXPECTED RESULT
Parsing continues normally.

SOFTWARE/OS VERSIONS
kdevelop 6.3.250802 (25.08.2)
Linux/KDE Plasma:  OS: Arch Linux
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: Qt 6.10.0
llvm-config --version: 21.1.4

ADDITIONAL INFORMATION
Segfault in line: kdevplatform/serialization/itemrepository.h:734
(gdb)
frame 4
p m_nextBucketHash
$1 = (unsigned short *) 0x7fff8d8a02cd
up
info locals
bucketPtr = 0x7fff2cad2a90

I don't see immediately what lead to the std::fill_n segfaulting, but its clearly going out-of-bounds.
I have saved a core dump and I'll try track if KDevelop crashes in same way each time. 

Thread 42 "Queue(0x5555565" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff497fa6c0 (LWP 12580)]
0x00007ffff3ea940f in std::__fill_a1<unsigned short*, int> (__first=<optimized out>, __last=<optimized out>, __value=<optimized out>, __first=<optimized out>, __last=<optimized out>, __value=<optimized out>)
    at /usr/include/c++/15.2.1/bits/stl_algobase.h:925
925		*__first = __val;
(gdb) bt
#0  0x00007ffff3ea940f in std::__fill_a1<unsigned short*, int> (__first=0x7fff8d8a02cd, __last=0x7fff8d8a1c67, __value=<optimized out>, __first=<optimized out>, __last=<optimized out>, __value=<optimized out>)
    at /usr/include/c++/15.2.1/bits/stl_algobase.h:925
#1  std::__fill_a<unsigned short*, int> (__first=0x7fff8d8a02cd, __last=0x7fff8d8a1c67, __value=<optimized out>, __first=<optimized out>, __last=<optimized out>, __value=<optimized out>) at /usr/include/c++/15.2.1/bits/stl_algobase.h:979
#2  std::__fill_n_a<unsigned short*, int, int> (__first=0x7fff8d8a02cd, __n=3277, __value=<optimized out>, __first=<optimized out>, __n=<optimized out>, __value=<optimized out>) at /usr/include/c++/15.2.1/bits/stl_algobase.h:1148
#3  std::fill_n<unsigned short*, KDevelop::Bucket<KDevelop::CodeModelRepositoryItem, KDevelop::CodeModelRequestItem, true, 0u>::{unnamed type#3}, int>(KDevelop::Bucket<KDevelop::CodeModelRepositoryItem, KDevelop::CodeModelRequestItem, true, 0u>::{unnamed type#3}, KDevelop::Bucket<KDevelop::CodeModelRepositoryItem, KDevelop::CodeModelRequestItem, true, 0u>::{unnamed type#3}, int const&)
    (__first=0x7fff8d8a02cd, __n=KDevelop::Bucket<KDevelop::CodeModelRepositoryItem, KDevelop::CodeModelRequestItem, true, 0>::NextBucketHashSize, __value=<optimized out>) at /usr/include/c++/15.2.1/bits/stl_algobase.h:1178
#4  KDevelop::Bucket<KDevelop::CodeModelRepositoryItem, KDevelop::CodeModelRequestItem, true, 0u>::takeNextBucketHash (this=0x7fff2cad2a90) at /usr/src/debug/kdevelop/kdevelop-25.08.2/kdevplatform/serialization/itemrepository.h:734
#5  KDevelop::ItemRepository<KDevelop::CodeModelRepositoryItem, KDevelop::CodeModelRequestItem, true, QMutex, 0u, 1048576u>::convertMonsterBucket
    (this=this@entry=0x7ffff4484ab0 <KDevelop::ItemRepositoryFor<KDevelop::CodeModel>::repo()::repo>, bucketNumber=bucketNumber@entry=36, extent=<optimized out>)
    at /usr/src/debug/kdevelop/kdevelop-25.08.2/kdevplatform/serialization/itemrepository.h:2144
#6  0x00007ffff3eb023b in KDevelop::ItemRepository<KDevelop::CodeModelRepositoryItem, KDevelop::CodeModelRequestItem, true, QMutex, 0u, 1048576u>::index (this=<optimized out>, request=<optimized out>)
    at /usr/src/debug/kdevelop/kdevelop-25.08.2/kdevplatform/serialization/itemrepository.h:1396
#7  0x00007ffff3eb0b42 in operator() (__closure=<optimized out>, repo=warning: RTTI symbol not found for class 'KDevelop::ItemRepository<KDevelop::CodeModelRepositoryItem, KDevelop::CodeModelRequestItem, true, QMutex, 0u, 1048576u>'
...) at /usr/src/debug/kdevelop/kdevelop-25.08.2/kdevplatform/language/duchain/codemodel.cpp:242
#8  KDevelop::LockedItemRepository::write<KDevelop::CodeModel, KDevelop::CodeModel::addItem(const KDevelop::IndexedString&, const KDevelop::IndexedQualifiedIdentifier&, KDevelop::CodeModelItem::Kind)::<lambda(KDevelop::CodeModelRepo&)> >
    (op=<optimized out>) at /usr/src/debug/kdevelop/kdevelop-25.08.2/kdevplatform/serialization/itemrepository.h:2552
#9  KDevelop::CodeModel::addItem (this=<optimized out>, file=<optimized out>, id=<optimized out>, kind=<optimized out>) at /usr/src/debug/kdevelop/kdevelop-25.08.2/kdevplatform/language/duchain/codemodel.cpp:199
#10 0x00007ffff3f126db in KDevelop::Declaration::setInSymbolTable (this=0x7fff2cad2730, inSymbolTable=<optimized out>) at /usr/src/debug/kdevelop/kdevelop-25.08.2/kdevplatform/language/duchain/declaration.cpp:622
#11 0x00007fff86c5da52 in (anonymous namespace)::Visitor::createDeclarationCommon<(CXCursorKind)1, KDevelop::ClassMemberDeclaration> (this=0x7fff497f83a0, cursor=..., id=...)
    at /usr/src/debug/kdevelop/kdevelop-25.08.2/plugins/clang/duchain/builder.cpp:448
#12 0x00007fff86c4c9f1 in (anonymous namespace)::Visitor::createDeclaration<(CXCursorKind)1, KDevelop::ClassMemberDeclaration> (context=0x0, this=0x7fff497f83a0, cursor=..., id=...)
    at /usr/src/debug/kdevelop/kdevelop-25.08.2/plugins/clang/duchain/builder.cpp:456
#13 (anonymous namespace)::Visitor::buildDeclaration<(CXCursorKind)6, KDevelop::ClassMemberDeclaration, false> (this=this@entry=0x7fff497f83a0, cursor=...)
    at /usr/src/debug/kdevelop/kdevelop-25.08.2/plugins/clang/duchain/builder.cpp:1296
#14 0x00007fff86c54d0e in (anonymous namespace)::Visitor::dispatchCursor<(CXCursorKind)15> (this=0x7fff497f83a0, cursor=..., parent=...) at /usr/src/debug/kdevelop/kdevelop-25.08.2/plugins/clang/duchain/builder.cpp:988
#15 (anonymous namespace)::visitCursor (cursor=..., parent=..., data=0x7fff497f83a0) at /usr/src/debug/kdevelop/kdevelop-25.08.2/plugins/clang/duchain/builder.cpp:1702
#16 0x00007fff7deaf85e in clang::cxcursor::CursorVisitor::Visit () at /usr/src/debug/clang/clang-21.1.4.src/tools/libclang/CIndex.cpp:227
#17 0x00007fff7deb0f84 in clang::cxcursor::CursorVisitor::handleDeclForVisitation () at /usr/src/debug/clang/clang-21.1.4.src/tools/libclang/CIndex.cpp:696
#18 0x00007fff7deb1358 in clang::cxcursor::CursorVisitor::VisitDeclContext () at /usr/src/debug/clang/clang-21.1.4.src/tools/libclang/CIndex.cpp:657
#19 0x00007fff7dead9e1 in clang::declvisitor::Base<std::add_pointer, clang::cxcursor::CursorVisitor, bool>::Visit () at /usr/src/debug/clang/clang-21.1.4.src/build/include/clang/AST/DeclNodes.inc:432
#20 clang::cxcursor::CursorVisitor::VisitChildren () at /usr/src/debug/clang/clang-21.1.4.src/tools/libclang/CIndex.cpp:516
#21 0x00007fff7deb6c59 in clang_visitChildren () at /usr/src/debug/clang/clang-21.1.4.src/tools/libclang/CIndex.cpp:5269
#22 0x00007fff86c50b00 in (anonymous namespace)::Visitor::buildDeclaration<(CXCursorKind)2, KDevelop::ClassDeclaration, true> (this=this@entry=0x7fff497f83a0, cursor=...)
    at /usr/src/debug/kdevelop/kdevelop-25.08.2/plugins/clang/duchain/builder.cpp:1293
#23 0x00007fff86c51299 in (anonymous namespace)::Visitor::dispatchCursor<(CXCursorKind)2, (Decision)0, (Decision)0> (this=0x7fff497f83a0, cursor=..., parent=...)
    at /usr/src/debug/kdevelop/kdevelop-25.08.2/plugins/clang/duchain/builder.cpp:1007
#24 (anonymous namespace)::Visitor::dispatchCursor<(CXCursorKind)2, (Decision)0, (Decision)2> (this=0x7fff497f83a0, cursor=..., parent=...) at /usr/src/debug/kdevelop/kdevelop-25.08.2/plugins/clang/duchain/builder.cpp:982
#25 0x00007fff86c578b8 in (anonymous namespace)::Visitor::dispatchCursor<(CXCursorKind)2> (this=0x7fff497f83a0, cursor=..., parent=...) at /usr/src/debug/kdevelop/kdevelop-25.08.2/plugins/clang/duchain/builder.cpp:971
#26 (anonymous namespace)::visitCursor (cursor=..., parent=..., data=0x7fff497f83a0) at /usr/src/debug/kdevelop/kdevelop-25.08.2/plugins/clang/duchain/builder.cpp:1676
#27 0x00007fff7deaf85e in clang::cxcursor::CursorVisitor::Visit () at /usr/src/debug/clang/clang-21.1.4.src/tools/libclang/CIndex.cpp:227
#28 0x00007fff7deb0f84 in clang::cxcursor::CursorVisitor::handleDeclForVisitation () at /usr/src/debug/clang/clang-21.1.4.src/tools/libclang/CIndex.cpp:696
#29 0x00007fff7deb1358 in clang::cxcursor::CursorVisitor::VisitDeclContext () at /usr/src/debug/clang/clang-21.1.4.src/tools/libclang/CIndex.cpp:657
#30 0x00007fff7deae5a1 in clang::cxcursor::CursorVisitor::VisitLinkageSpecDecl () at /usr/src/debug/clang/clang-21.1.4.src/tools/libclang/CIndex.cpp:1612
#31 clang::declvisitor::Base<std::add_pointer, clang::cxcursor::CursorVisitor, bool>::Visit () at /usr/src/debug/clang/clang-21.1.4.src/build/include/clang/AST/DeclNodes.inc:48
#32 clang::cxcursor::CursorVisitor::VisitChildren () at /usr/src/debug/clang/clang-21.1.4.src/tools/libclang/CIndex.cpp:516
#33 0x00007fff7deaf893 in clang::cxcursor::CursorVisitor::Visit () at /usr/src/debug/clang/clang-21.1.4.src/tools/libclang/CIndex.cpp:235
#34 0x00007fff7deb0f84 in clang::cxcursor::CursorVisitor::handleDeclForVisitation () at /usr/src/debug/clang/clang-21.1.4.src/tools/libclang/CIndex.cpp:696
#35 0x00007fff7deb1358 in clang::cxcursor::CursorVisitor::VisitDeclContext () at /usr/src/debug/clang/clang-21.1.4.src/tools/libclang/CIndex.cpp:657
#36 0x00007fff7deae874 in clang::cxcursor::CursorVisitor::VisitChildren () at /usr/src/debug/clang/clang-21.1.4.src/tools/libclang/CIndex.cpp:550
#37 0x00007fff7deb6c59 in clang_visitChildren () at /usr/src/debug/clang/clang-21.1.4.src/tools/libclang/CIndex.cpp:5269
#38 0x00007fff86c52439 in (anonymous namespace)::Visitor::Visitor (this=0x7fff497f83a0, tu=<optimized out>, file=<optimized out>, includes=<optimized out>, update=<optimized out>)
    at /usr/src/debug/kdevelop/kdevelop-25.08.2/plugins/clang/duchain/builder.cpp:1595
#39 Builder::visit (tu=<optimized out>, file=<optimized out>, includes=<optimized out>, update=<optimized out>) at /usr/src/debug/kdevelop/kdevelop-25.08.2/plugins/clang/duchain/builder.cpp:1744
#40 0x00007fff86c73fb6 in ClangHelpers::buildDUChain (file=<optimized out>, imports=..., session=..., features=..., features@entry=..., includedFiles=..., unsavedRevisions=..., parseDocument=..., index=0x555557469bd0, abortFunction=...)
--Type <RET> for more, q to quit, c to continue without paging--c
    at /usr/src/debug/kdevelop/kdevelop-25.08.2/plugins/clang/duchain/clanghelpers.cpp:209
#41 0x00007fff86d04d51 in ClangParseJob::run (this=<optimized out>) at /usr/src/debug/kdevelop/kdevelop-25.08.2/plugins/clang/clangparsejob.cpp:323
#42 0x00007ffff0faa522 in ThreadWeaver::IdDecorator::run (this=<optimized out>, self=..., thread=0x7fff28001440) at /usr/src/debug/threadweaver/threadweaver-6.19.0/src/iddecorator.cpp:50
#43 0x00007ffff0faa311 in ThreadWeaver::Executor::run (this=<optimized out>, job=<optimized out>, thread=<optimized out>) at /usr/src/debug/threadweaver/threadweaver-6.19.0/src/executor.cpp:29
#44 0x00007ffff0fab20e in ThreadWeaver::Job::execute (this=<optimized out>, self=..., th=0x7fff28001440) at /usr/src/debug/threadweaver/threadweaver-6.19.0/src/job.cpp:64
#45 0x00007ffff0fb3a99 in ThreadWeaver::Thread::run (this=0x7fff28001440) at /usr/src/debug/threadweaver/threadweaver-6.19.0/src/thread.cpp:94
#46 0x00007ffff6530ca9 in operator() (__closure=<optimized out>) at /usr/src/debug/qt6-base/qtbase/src/corelib/thread/qthread_unix.cpp:437
#47 (anonymous namespace)::terminate_on_exception<QThreadPrivate::start(void*)::<lambda()> > (t=<optimized out>) at /usr/src/debug/qt6-base/qtbase/src/corelib/thread/qthread_unix.cpp:367
#48 QThreadPrivate::start (arg=0x7fff28001440) at /usr/src/debug/qt6-base/qtbase/src/corelib/thread/qthread_unix.cpp:397
#49 0x00007ffff5a969cb in start_thread (arg=<optimized out>) at pthread_create.c:448
#50 0x00007ffff5b1aa0c in __GI___clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
Comment 1 Igor Kushnir 2025-11-05 18:38:45 UTC

*** This bug has been marked as a duplicate of bug 488043 ***