Bug 343950

Summary: Clang crashes when parsing Linux Kernel source [clang::comments::Lexer::lexVerbatimBlockFirstLine]
Product: [Applications] kdevelop Reporter: Lucas Tanure <ltanure>
Component: Language Support: CPP (Clang-based)Assignee: kdevelop-bugs-null
Status: RESOLVED DUPLICATE    
Severity: grave CC: david.nolden.kde, kfunk
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: New gdb log
kdevelop stdout and stderr

Description Lucas Tanure 2015-02-08 23:19:16 UTC
Kdevelop crashes after a few seconds parsing linux kernel source

Compiled the last clang, kdevplatform, kdevelop, kdev-clang
Import Linux source to kdevelop, the top makefile form linux tree.

GDB LOG (Backtrace) :
https://www.dropbox.com/s/ttdj22myw84h07h/gdb.log?dl=0

Stdout and Stderr : 
https://www.dropbox.com/s/ke4iovxx8alis9j/kdev.log?dl=0



Reproducible: Always

Steps to Reproduce:
1. Compile the last clang, kdevplatform, kdevelop, kdev-clang
2. Open Kdevelop and import Linux Kernel top make file

Actual Results:  
ABORT
#0  0x00007fffef77aa97 in raise () from /usr/lib/libc.so.6
#1  0x00007fffef77be6a in abort () from /usr/lib/libc.so.6
#2  0x00007fffef7738bd in __assert_fail_base () from /usr/lib/libc.so.6
#3  0x00007fffef773972 in __assert_fail () from /usr/lib/libc.so.6
#4  0x00007fffa6162765 in clang::comments::Lexer::lexVerbatimBlockFirstLine (this=0x7fff9f7fc5e0, T=...) at /home/tanure/workspace/src/llvm/tools/clang/lib/AST/CommentLexer.cpp:468
#5  0x00007fffa61629e4 in clang::comments::Lexer::lexVerbatimBlockBody (this=0x7fff9f7fc5e0, T=...) at /home/tanure/workspace/src/llvm/tools/clang/lib/AST/CommentLexer.cpp:517
#6  0x00007fffa6161daa in clang::comments::Lexer::lexCommentText (this=0x7fff9f7fc5e0, T=...) at /home/tanure/workspace/src/llvm/tools/clang/lib/AST/CommentLexer.cpp:295
#7  0x00007fffa6163856 in clang::comments::Lexer::lex (this=0x7fff9f7fc5e0, T=...) at /home/tanure/workspace/src/llvm/tools/clang/lib/AST/CommentLexer.cpp:802


GDB LOG (Backtrace) :
https://www.dropbox.com/s/ttdj22myw84h07h/gdb.log?dl=0

Stdout and Stderr : 
https://www.dropbox.com/s/ke4iovxx8alis9j/kdev.log?dl=0
Comment 1 Lucas Tanure 2015-02-08 23:29:25 UTC
Heads:

kdevplatform: a394d09c4a91098049525b2201904cfd9f7ee3fe
kdevelop: fb94b437ab128a688927d3fe2ae4a610fe06d261
kdev-clang: 35953e7920c848d17bc29238c77784cc2304ddd0
llvm: b3d4cc50caa36668e226834324d6756ecaef3217
clang: 33947ed22c57e11e7aa88e803bfdd664fe50412f
Comment 2 Lucas Tanure 2015-02-08 23:30:33 UTC
Hi, 

I would some help to be solve this issue. 

Thanks
Lucas Tanure
Comment 3 Kevin Funk 2015-02-08 23:55:01 UTC
I still don't understand why you just don't compile LLVM/Clang in release mode? We haven't seen "real" crashes with them in release mode yet.

With LLVM/Clang in *debug* / assertions enabled I'm running into crashes  (similar to yours) even with the simplest project (and no, didn't investigate *why* this is happening yet).

Of course, we need to investigate, but as a work-around just compile in release mode...
Comment 4 Lucas Tanure 2015-02-09 01:40:00 UTC
I did tried with release llvm. I will try again.
Comment 5 Lucas Tanure 2015-02-09 03:07:39 UTC
The same issue with llvm release:
#0  0x00007fffef77aa97 in raise () from /usr/lib/libc.so.6
#1  0x00007fffef77be6a in abort () from /usr/lib/libc.so.6
#2  0x00007ffff03a497f in QMessageLogger::fatal(char const*, ...) const () from /usr/lib/libQt5Core.so.5
#3  0x00007ffff039fc8e in qt_assert(char const*, char const*, int) () from /usr/lib/libQt5Core.so.5
#4  0x00007fffedf87d3d in KDevelop::ItemRepository<KDevelop::PersistentSymbolTableItem, KDevelop::PersistentSymbolTableRequestItem, true, false, 0u, 1048576u>::deleteBucket (this=0x7fff9000a320, bucketNumber=609) at /home/tanure/workspace/src/kdevplatform/serialization/itemrepository.h:2331
#5  0x00007fffedf8276b in KDevelop::ItemRepository<KDevelop::PersistentSymbolTableItem, KDevelop::PersistentSymbolTableRequestItem, true, false, 0u, 1048576u>::convertMonsterBucket (this=0x7fff9000a320, bucketNumber=609, extent=0) at /home/tanure/workspace/src/kdevplatform/serialization/itemrepository.h:2046
#6  0x00007fffedf7dfb5 in KDevelop::ItemRepository<KDevelop::PersistentSymbolTableItem, KDevelop::PersistentSymbolTableRequestItem, true, false, 0u, 1048576u>::deleteItem (this=0x7fff9000a320, index=39911426) at /home/tanure/workspace/src/kdevplatform/serialization/itemrepository.h:1564
#7  0x00007fffedf7a9d3 in KDevelop::PersistentSymbolTable::addDeclaration (this=0x7fffef11d4f8 <KDevelop::PersistentSymbolTable::self()::ret>, id=..., declaration=...) at /home/tanure/workspace/src/kdevplatform/language/duchain/persistentsymboltable.cpp:197
#8  0x00007fffedf15ef8 in KDevelop::Declaration::setInSymbolTable (this=0x7fff7c2dc180, inSymbolTable=true) at /home/tanure/workspace/src/kdevplatform/language/duchain/declaration.cpp:615
#9  0x00007fffedf14b62 in KDevelop::Declaration::setContext (this=0x7fff7c2dc180, context=0x7fff7d105740, anonymous=false) at /home/tanure/workspace/src/kdevplatform/language/duchain/declaration.cpp:342
#10 0x00007fffd68f54dd in TUDUChain::createDeclaration<(CXCursorKind)9, KDevelop::Declaration> (this=0x7fff8f7fd6c0, cursor=..., id=..., context=0x0) at /home/tanure/workspace/src/kdev-clang/duchain/tuduchain.h:244
#11 0x00007fffd68ec478 in TUDUChain::buildDeclaration<(CXCursorKind)9, KDevelop::Declaration, false> (this=0x7fff8f7fd6c0, cursor=...) at /home/tanure/workspace/src/kdev-clang/duchain/tuduchain.h:196
#12 0x00007fffd68e4ae3 in TUDUChain::dispatchCursor<(CXCursorKind)9, (Decision)1, (Decision)1, (detail::enabler)0> (this=0x7fff8f7fd6c0, cursor=..., parent=...) at /home/tanure/workspace/src/kdev-clang/duchain/tuduchain.h:150
#13 0x00007fffd68e188f in TUDUChain::dispatchCursor<(CXCursorKind)9, (Decision)2, (detail::enabler)0> (this=0x7fff8f7fd6c0, cursor=..., parent=...) at /home/tanure/workspace/src/kdev-clang/duchain/tuduchain.h:112
#14 0x00007fffd68df01b in TUDUChain::visitCursor (cursor=..., parent=..., data=0x7fff8f7fd6c0) at /home/tanure/workspace/src/kdev-clang/duchain/tuduchain.cpp:299
#15 0x00007fffa6a2cde4 in clang::cxcursor::CursorVisitor::Visit(CXCursor, bool) () from /opt/llvm/lib/libclang.so.3.7
#16 0x00007fffa6a2dcc6 in clang::cxcursor::CursorVisitor::VisitDeclContext(clang::DeclContext*) () from /opt/llvm/lib/libclang.so.3.7
#17 0x00007fffa6a2cbc9 in clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) () from /opt/llvm/lib/libclang.so.3.7
#18 0x00007fffa6a32571 in clang_visitChildren () from /opt/llvm/lib/libclang.so.3.7
#19 0x00007fffd68de49e in TUDUChain::TUDUChain (this=0x7fff8f7fd6c0, tu=0x7fff6408b700, file=0x7fff6408ede0, includes=..., update=false) at /home/tanure/workspace/src/kdev-clang/duchain/tuduchain.cpp:199
#20 0x00007fffd68c526c in ClangHelpers::buildDUChain (file=0x7fff6408ede0, imports=..., session=..., features=KDevelop::TopDUContext::VisibleDeclarationsAndContexts, includedFiles=..., index=0x50fe4e0) at /home/tanure/workspace/src/kdev-clang/duchain/clanghelpers.cpp:173
#21 0x00007fffd68a653f in ClangParseJob::run (this=0x4d2e830) at /home/tanure/workspace/src/kdev-clang/clangparsejob.cpp:350
#22 0x00007fffec6a8090 in ThreadWeaver::IdDecorator::run(QSharedPointer<ThreadWeaver::JobInterface>, ThreadWeaver::Thread*) () from /usr/lib/libKF5ThreadWeaver.so.5
#23 0x00007fffec6a87d0 in ThreadWeaver::Executor::run(QSharedPointer<ThreadWeaver::JobInterface> const&, ThreadWeaver::Thread*) () from /usr/lib/libKF5ThreadWeaver.so.5
#24 0x00007fffec6a753a in ThreadWeaver::Job::execute(QSharedPointer<ThreadWeaver::JobInterface> const&, ThreadWeaver::Thread*) () from /usr/lib/libKF5ThreadWeaver.so.5
#25 0x00007fffec6a6caa in ThreadWeaver::Thread::run() () from /usr/lib/libKF5ThreadWeaver.so.5
#26 0x00007ffff03b75ee in ?? () from /usr/lib/libQt5Core.so.5
#27 0x00007fffe9400314 in start_thread () from /usr/lib/libpthread.so.0
Comment 6 Kevin Funk 2015-02-09 08:33:38 UTC
Well, it's a totally different one (because this time it's not Clang's fault).

Did you try with a clean cache directory? Start kdevelop like this: "CLEAR_DUCHAIN_DIR=1 kdevelop"
Comment 7 Lucas Tanure 2015-02-10 22:55:29 UTC
Restart from begging : Deleted session and used "CLEAR_DUCHAIN_DIR=1"

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffb1e4d700 (LWP 28060)]
0x00007fffef7794b7 in raise () from /usr/lib/libc.so.6
#0  0x00007fffef7794b7 in raise () from /usr/lib/libc.so.6
#1  0x00007fffef77a88a in abort () from /usr/lib/libc.so.6
#2  0x00007ffff03a397f in QMessageLogger::fatal(char const*, ...) const () from /usr/lib/libQt5Core.so.5
#3  0x00007ffff039ec8e in qt_assert(char const*, char const*, int) () from /usr/lib/libQt5Core.so.5
#4  0x00007fffedf86f17 in KDevelop::ItemRepository<KDevelop::PersistentSymbolTableItem, KDevelop::PersistentSymbolTableRequestItem, true, false, 0u, 1048576u>::deleteBucket (this=0x7fffc80a20f0, bucketNumber=622) at /home/tanure/workspace/src/kdevplatform/serialization/itemrepository.h:2331
#5  0x00007fffedf81945 in KDevelop::ItemRepository<KDevelop::PersistentSymbolTableItem, KDevelop::PersistentSymbolTableRequestItem, true, false, 0u, 1048576u>::convertMonsterBucket (this=0x7fffc80a20f0, bucketNumber=622, extent=0) at /home/tanure/workspace/src/kdevplatform/serialization/itemrepository.h:2046
#6  0x00007fffedf7d16f in KDevelop::ItemRepository<KDevelop::PersistentSymbolTableItem, KDevelop::PersistentSymbolTableRequestItem, true, false, 0u, 1048576u>::deleteItem (this=0x7fffc80a20f0, index=40763394) at /home/tanure/workspace/src/kdevplatform/serialization/itemrepository.h:1564
#7  0x00007fffedf79b8f in KDevelop::PersistentSymbolTable::addDeclaration (this=0x7fffef11c4f8 <KDevelop::PersistentSymbolTable::self()::ret>, id=..., declaration=...) at /home/tanure/workspace/src/kdevplatform/language/duchain/persistentsymboltable.cpp:201
#8  0x00007fffedf1508a in KDevelop::Declaration::setInSymbolTable (this=0x7fffaadb86a0, inSymbolTable=true) at /home/tanure/workspace/src/kdevplatform/language/duchain/declaration.cpp:615
#9  0x00007fffedf13cf4 in KDevelop::Declaration::setContext (this=0x7fffaadb86a0, context=0x7fff89f4e610, anonymous=false) at /home/tanure/workspace/src/kdevplatform/language/duchain/declaration.cpp:342
#10 0x00007fffa7d7e4dd in TUDUChain::createDeclaration<(CXCursorKind)9, KDevelop::Declaration> (this=0x7fffb1e4c6c0, cursor=..., id=..., context=0x0) at /home/tanure/workspace/src/kdev-clang/duchain/tuduchain.h:244
#11 0x00007fffa7d75478 in TUDUChain::buildDeclaration<(CXCursorKind)9, KDevelop::Declaration, false> (this=0x7fffb1e4c6c0, cursor=...) at /home/tanure/workspace/src/kdev-clang/duchain/tuduchain.h:196
#12 0x00007fffa7d6dae3 in TUDUChain::dispatchCursor<(CXCursorKind)9, (Decision)1, (Decision)1, (detail::enabler)0> (this=0x7fffb1e4c6c0, cursor=..., parent=...) at /home/tanure/workspace/src/kdev-clang/duchain/tuduchain.h:150
#13 0x00007fffa7d6a88f in TUDUChain::dispatchCursor<(CXCursorKind)9, (Decision)2, (detail::enabler)0> (this=0x7fffb1e4c6c0, cursor=..., parent=...) at /home/tanure/workspace/src/kdev-clang/duchain/tuduchain.h:112
#14 0x00007fffa7d6801b in TUDUChain::visitCursor (cursor=..., parent=..., data=0x7fffb1e4c6c0) at /home/tanure/workspace/src/kdev-clang/duchain/tuduchain.cpp:299
#15 0x00007fffa6e00b34 in clang::cxcursor::CursorVisitor::Visit(CXCursor, bool) () from /opt/llvm/lib/libclang.so.3.7
#16 0x00007fffa6e01a16 in clang::cxcursor::CursorVisitor::VisitDeclContext(clang::DeclContext*) () from /opt/llvm/lib/libclang.so.3.7
#17 0x00007fffa6e00919 in clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) () from /opt/llvm/lib/libclang.so.3.7
#18 0x00007fffa6e06191 in clang_visitChildren () from /opt/llvm/lib/libclang.so.3.7
#19 0x00007fffa7d6749e in TUDUChain::TUDUChain (this=0x7fffb1e4c6c0, tu=0x7fffa0000e20, file=0x7fffa0095800, includes=..., update=false) at /home/tanure/workspace/src/kdev-clang/duchain/tuduchain.cpp:199
#20 0x00007fffa7d4e26c in ClangHelpers::buildDUChain (file=0x7fffa0095800, imports=..., session=..., features=KDevelop::TopDUContext::VisibleDeclarationsAndContexts, includedFiles=..., index=0x507ead0) at /home/tanure/workspace/src/kdev-clang/duchain/clanghelpers.cpp:173
#21 0x00007fffa7d2f53f in ClangParseJob::run (this=0x4ff6400) at /home/tanure/workspace/src/kdev-clang/clangparsejob.cpp:350
#22 0x00007fffec6a7090 in ThreadWeaver::IdDecorator::run(QSharedPointer<ThreadWeaver::JobInterface>, ThreadWeaver::Thread*) () from /usr/lib/libKF5ThreadWeaver.so.5
#23 0x00007fffec6a77d0 in ThreadWeaver::Executor::run(QSharedPointer<ThreadWeaver::JobInterface> const&, ThreadWeaver::Thread*) () from /usr/lib/libKF5ThreadWeaver.so.5
#24 0x00007fffec6a653a in ThreadWeaver::Job::execute(QSharedPointer<ThreadWeaver::JobInterface> const&, ThreadWeaver::Thread*) () from /usr/lib/libKF5ThreadWeaver.so.5
#25 0x00007fffec6a5caa in ThreadWeaver::Thread::run() () from /usr/lib/libKF5ThreadWeaver.so.5
#26 0x00007ffff03b65ee in ?? () from /usr/lib/libQt5Core.so.5
#27 0x00007fffe93fe374 in start_thread () from /usr/lib/libpthread.so.0
#28 0x00007fffef82e27d in clone () from /usr/lib/libc.so.6
Comment 8 Lucas Tanure 2015-02-10 22:56:11 UTC
Created attachment 91017 [details]
New gdb log
Comment 9 Lucas Tanure 2015-02-10 22:58:21 UTC
Created attachment 91018 [details]
kdevelop stdout and stderr
Comment 10 Lucas Tanure 2015-03-06 19:03:08 UTC

*** This bug has been marked as a duplicate of bug 272408 ***
Comment 11 Kevin Funk 2015-03-15 09:28:27 UTC
@David, by any chance: Could you have a look at this? I think no-one in the current KDevelop team really grasps that code at the moment, any help is appreciated.