Bug 418220 - crash on libclang parsing
Summary: crash on libclang parsing
Status: RESOLVED UPSTREAM
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (Clang-based) (show other bugs)
Version: 5.5.0
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-26 13:22 UTC by Marián Konček
Modified: 2020-03-02 21:35 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Source file that causes the crash (1.07 KB, text/x-c++hdr)
2020-02-26 13:22 UTC, Marián Konček
Details
Stack trace (not exactly corresponding to the the source file) (48.79 KB, text/plain)
2020-02-26 13:23 UTC, Marián Konček
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marián Konček 2020-02-26 13:22:05 UTC
Created attachment 126423 [details]
Source file that causes the crash

Description of problem:
Kdevelop crashes when parsing C++ code using libclang.

Version-Release number of selected component (if applicable):
kdevelop-5.5.0-1.fc31.src.rpm
clang-9.0.0-1.fc31.src.rpm

How reproducible:
In KDevelop create an empty .cpp file and #include the attached .hpp file. KDevelop then crashes.

Additional info:
In my case if I have the same code directly in .cpp file it does not crash (but I have disabled background parsing, but KDevelop does parse code when switching tabs).

###
imporant lines: 19-30 of the provided source file.

Currently clang does not compile code that uses "auto&" as parameters.
Note that i am using "auto&" as function parameters on other places within KDevelop and although it doesn't like them, most of the code is parsed anyway.

The crash does not happen when:
1) changing the auto& parameter for a proper template typename parameter as in:

template<typename Self>
static auto static_find(Self& self, const Key_type& key)

2) replacing the structured binding for a single variable initialization.
Comment 1 Marián Konček 2020-02-26 13:23:04 UTC
Created attachment 126424 [details]
Stack trace (not exactly corresponding to the the source file)
Comment 2 Marián Konček 2020-02-26 13:27:42 UTC
To be precise, Kdevelop crashes when I press F5 or simply force reparsing on the .cpp file.
Comment 3 Milian Wolff 2020-03-02 21:35:38 UTC
could you please report this bug upstream to clang? that crash dump is deep within llvm/clang codebase:

Thread 28 (Thread 0x7f5557fff700 (LWP 647416)):
[KCrash Handler]
#6  clang::Decl::setInvalidDecl (this=0x0, Invalid=true) at ../lib/AST/DeclBase.cpp:132
#7  0x00007f55c0beaeb0 in clang::Decl::setInvalidDecl (this=this@entry=0x7f5551d95848, Invalid=<optimized out>) at ../lib/AST/DeclBase.cpp:149
#8  0x00007f55bb48fb14 in clang::ASTDeclReader::VisitDecl (this=0x7f5557ffbb60, D=0x7f5551d95848) at /usr/include/llvm/ADT/SmallVector.h:148
#9  0x00007f55bb4909b5 in clang::ASTDeclReader::VisitNamedDecl (this=this@entry=0x7f5557ffbb60, ND=ND@entry=0x7f5551d95848) at ../lib/Serialization/ASTReaderDecl.cpp:657
#10 0x00007f55bb490b95 in clang::ASTDeclReader::VisitValueDecl (this=0x7f5557ffbb60, VD=0x7f5551d95848) at ../lib/Serialization/ASTReaderDecl.cpp:806
#11 0x00007f55bb490c2d in clang::ASTDeclReader::VisitDeclaratorDecl (this=this@entry=0x7f5557ffbb60, DD=DD@entry=0x7f5551d95848) at ../lib/Serialization/ASTReaderDecl.cpp:825
#12 0x00007f55bb4b0830 in clang::ASTDeclReader::VisitVarDeclImpl (this=this@entry=0x7f5557ffbb60, VD=VD@entry=0x7f5551d95848) at ../lib/Serialization/ASTReaderDecl.cpp:1362
#13 0x00007f55bb4b1377 in clang::ASTDeclReader::VisitVarDecl (VD=0x7f5551d95848, this=0x7f5557ffbb60) at ../lib/Serialization/ASTReaderDecl.cpp:378
#14 clang::ASTDeclReader::VisitDecompositionDecl (this=0x7f5557ffbb60, DD=0x7f5551d95848) at ../lib/Serialization/ASTReaderDecl.cpp:1464
#15 0x00007f55bb4b3ed6 in clang::ASTDeclReader::Visit (this=0x7f5557ffbb60, D=0x7f5551d95848) at ../lib/Serialization/ASTReaderDecl.cpp:522
#16 0x00007f55bb4b4976 in clang::ASTReader::ReadDeclRecord (this=0x7f55214af1c0, ID=83898) at ../lib/Serialization/ASTReaderDecl.cpp:3967
#17 0x00007f55bb4144c1 in clang::ASTReader::GetDecl (this=0x7f55214af1c0, ID=83898) at ../lib/Serialization/ASTReader.cpp:7800
#18 0x00007f55bb4b6af1 in clang::ASTReader::ReadDecl (I=<optimized out>, R=..., F=..., this=0x7f55214af1c0) at ../include/clang/Serialization/ASTReader.h:1870
#19 clang::ASTRecordReader::readDecl (this=<optimized out>) at ../include/clang/Serialization/ASTReader.h:2524
#20 clang::ASTStmtReader::ReadDecl (this=0x7f5557ffbff0) at ../lib/Serialization/ASTReaderStmt.cpp:91
#21 clang::ASTStmtReader::VisitDeclStmt (this=0x7f5557ffbff0, S=0x7f5551d95828) at ../lib/Serialization/ASTReaderStmt.cpp:348
#22 0x00007f55bb4c9979 in clang::ASTReader::ReadStmtFromStream (this=0x7f55214af1c0, F=...) at ../lib/Serialization/ASTReaderStmt.cpp:3464
#23 0x00007f55bb426326 in clang::ASTReader::GetExternalDeclStmt(unsigned long) () at ../lib/Serialization/ASTReader.cpp:7854
#24 0x00007f55c0be1e1b in clang::FunctionDecl::getBody (this=this@entry=0x7f5520780cf8, Definition=@0x7f5557ffc3c8: 0x7f5520780cf8) at ../include/clang/AST/ExternalASTSource.h:400
#25 0x00007f55c0ef5f48 in clang_getCursorDefinition (C=...) at ../tools/libclang/CIndex.cpp:6311
#26 0x00007f55c0ef64ad in clang_isCursorDefinition (C=...) at ../tools/libclang/CIndex.cpp:6434
#27 0x00007f55c0fdc7ca in (anonymous namespace)::Visitor::dispatchCursor<(CXCursorKind)21, (Decision)0, (Decision)2> (cursor=..., this=0x7f5557ffe640, parent=...) at /usr/src/debug/kdevelop-5.5.0-1.fc31.x86_64/plugins/clang/duchain/builder.cpp:930