KDevelop apparently crashes due to a file that contains "#pragma clang __debug crash"

Kevin Funk kfunk at kde.org
Tue Oct 25 21:50:07 UTC 2016


On Tuesday, 25 October 2016 11:11:22 CEST Kevin Funk wrote:
> On Tuesday, 25 October 2016 10:43:29 CEST Kevin Funk wrote:
> > On Tuesday, 25 October 2016 00:14:32 CEST Johannes Schaub wrote:
> > > I wanted to browse the LLVM/Clang GIT checkout, but indexing the
> > > project directory was very slow and sometimes it crashed (SIGILL and
> > > SIGSEGV).
> > > 
> > > When people in #kdevelop told me to enable logging using
> > > QT_LOGGING_RULES="kdev-clang=true", it turned out that clang kept
> > > crashing on files in clang's testsuites. Digging into one of the
> > > files, it contains
> > > 
> > >    #pragma clang __debug crash
> > > 
> > > This probably causes kdevelop to crash. In most cases (unfortunately)
> > > this appears to be catched by llvm's crash handler and transformed to
> > > a "return false".
> > 
> > Correct, usually libclang/LLVM handles these kind of crashes in its 'crash
> > recovery context' and recovers, as you can see here:
> > 
> > During parsing of llvm.git:
> > 
> > libclang: crash detected during parsing: {
> > 
> >   'source_filename' : '/home/kfunk/devel/src/llvm/tools/clang/test/Index/
> > 
> > crash-recovery.c'
> > 
> >   'command_line_args' : ['clang', '-ferror-limit=100', '-fspell-checking',
> > 
> > '- Wdocumentation', '-Wunused-parameter', '-Wunreachable-code', '-Wall',
> > '-
> > std=c99', '-nostdinc', '-xc', '-isystem/usr/local/include',
> > '-isystem/usr/lib/ llvm-3.8/lib/clang/3.8.1/include',
> > '-isystem/usr/include/x86_64-linux-gnu', '- isystem/usr/include',
> > '-I/home/kfunk/devel/src/llvm/include', '-I/home/kfunk/
> > devel/src/llvm/tools/clang/include', '-imacros', '/tmp/kdevelop.Vd3748'],
> > 'unsaved_files' : [...],
> > 
> >   'options' : 45,
> > 
> > }
> > [kdevelop(3748)/(default) unknown(0): clang_parseTranslationUnit2 return
> > with error code 2
> > [kdevelop(3748)/(default) unknown(0):   (start KDevelop with
> > `KDEV_CLANG_DISPLAY_DIAGS=1 kdevelop` to see more diagnostics)
> > [kdevelop(3748)/(default) unknown(0): Failed to parse translation unit: "/
> > home/kfunk/devel/src/llvm/tools/clang/test/Index/crash-recovery.c"
> > 
> > => No crash.
> > 
> > > My suspicion is that the SIGILL and SIGSEGV I
> > > noticed are due to this pragma and the inability to catch the crash in
> > > rare cases (the crash handler is best-effort).
> > 
> > Correct as well, it cannot possibly handle all cases. I just ran KDevelop
> > on llvm.git once more and it indeed crashes on the following file for me
> > -- investigating this now:
> > 
> > [kdevelop(5363)/(kdevplatform.language) unknown(0): creating parse-job
> > "/home/ kfunk/devel/src/llvm/tools/clang/test/SemaCXX/attr-gnu.cpp" new
> > count of active parse-jobs: 2
> > zsh: segmentation fault  KDEV_BACKGROUNDPARSER_MAXTHREADS=1 kdevelop -s
> > llvm
> Okay, that's fixed by:
>   https://reviews.llvm.org/D25308
> 
> That file even makes Clang (tested 3.8 & 3.9) itself unhappy:
> 
> $ clang++-3.9 -std=gnu++11 test/SemaCXX/attr-gnu.cpp
> (...)
> 1.      test/SemaCXX/attr-gnu.cpp:32:53: current parser token ';'
> 2.      test/SemaCXX/attr-gnu.cpp:32:1: parsing struct/union/class body 'Tu'
> clang: error: unable to execute command: Segmentation fault
> clang: error: clang frontend command failed due to signal (use -v to see
> invocation)
> 
> Anyhow, I can see only these two solutions to avoid running into problems
> like this:
> 
> - Use the latest libclang in KDevelop
>   (IOW the one compiled from llvm.git/clang.git)
> - Ignore directories containing regression tests / crash tests

Note: 

I've put a .kdev_ignore file into ./tools/clang/test/, KDevelop parses all of 
LLVM+Clang just fine now.

Works for you?

Cheers,
Kevin

> Hope that helps,
> Kevin
> 
> > > KDevelop should disable handling of this and similar pragmas in clang,
> > > if possible.
> > 
> > Problem with parsing the LLVM/Clang code of course: *If* there's a crash
> > in
> > libclang, and the crash is fixed in their trunk version, then usually a
> > regression test will be added as well. KDevelop, likely using an *older*
> > version of LLVM/Clang will try to parse the regression test... and crash.
> > 
> > I don't see how we could ever avoid this scenario. Of course there's the
> > possibility to make KDevelop ignore certain directories in the LLVM/Clang
> > tree [1] (e.g. the regression test suite).
> > 
> > Will investigate the crash now. For the time being, you could ignore the
> > directories containing 'dangerous' files: [1].
> > 
> > Regards,
> > Kevin
> > 
> > [1]
> > http://askubuntu.com/questions/136529/how-to-exclude-a-folder-from-a-kdeve
> > l
> > op-project


-- 
Kevin Funk | kfunk at kde.org | http://kfunk.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 163 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20161025/f164d2c0/attachment.sig>


More information about the KDevelop-devel mailing list