Bug 357407 - No semantic syntax highlighting due to "libclang: crash detected during parsing"
Summary: No semantic syntax highlighting due to "libclang: crash detected during parsing"
Status: RESOLVED DOWNSTREAM
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (Clang-based) (other bugs)
Version First Reported In: 4.90.91
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-01 23:45 UTC by Piotr Mierzwinski
Modified: 2021-01-26 18:30 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
kdevelop_libclang_crashes from 2016-02-29 (36.78 KB, text/plain)
2016-02-29 00:23 UTC, Piotr Mierzwinski
Details
kdevelop_libclang_crashes_20160229 KDEV_CLANG_DISPLAY_DIAGS=1 (102.37 KB, text/plain)
2016-02-29 19:18 UTC, Piotr Mierzwinski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Mierzwinski 2016-01-01 23:45:16 UTC
After open KDevelop with my project (C++ using Qt4 and based on cmake) and when kdevduchain cache has been rebuilt (before start I removed it) and project was reparsed I noticed that there is no semantic syntax highlighting (of course this option is turned on) in any opened C++ source code file, whereas when I using last built kdevelop (built on begin of December) all was fine.
Finally I found solution. You can find it on end this post.

After kdevelop is starting I get following message in terminal:
<cut>
kdevelop(24205)/(default) unknown: QWidget::insertAction: Attempt to insert null action
kdevelop(24205)/(default) unknown: QWidget::insertAction: Attempt to insert null action
kdevelop(24205)/(kdevelop.projectmanagers.cmake) unknown: Could not import CMake project "/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2" ('compile_commands.json' missing)
QInotifyFileSystemWatcherEngine::addPaths: inotify_add_watch failed: Nie ma takiego pliku ani katalogu
QInotifyFileSystemWatcherEngine::addPaths: inotify_add_watch failed: Nie ma takiego pliku ani katalogu
libclang: crash detected during parsing: {
  'source_filename' : '/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/plugins/vfs/zipsubsystem/zipsubsystem.cpp'
  'command_line_args' : ['-ferror-limit=100', '-fspell-checking', '-Wdocumentation', '-Wunused-parameter', '-Wunreachable-code', '-Wall', '-std=c++11', '-nostdinc', '-nostdinc++', '-xc++', '-include/usr/include/qt4/Qt/QtCore', '-include/usr/include/qt4/Qt/QtGui', '-include/usr/include/qt4/Qt/QtNetwork', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/include/c++/5', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/include/x86_64-linux-gnu/c++/5', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/include/c++/5/backward', '-isystem/usr/local/include', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/lib/llvm-3.6/lib/clang/3.6.2/include', '-isystem/usr/include/x86_64-linux-gnu', '-isystem/usr/include', '-imacros', '/tmp/kdevelop.K24205'],
  'unsaved_files' : [],
  'options' : 45,
}
kdevelop(24205)/(default) unknown: clang_parseTranslationUnit2 return with error code 2
kdevelop(24205)/(default) unknown: Failed to parse translation unit: "/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/plugins/vfs/zipsubsystem/zipsubsystem.cpp"
</cut>

The message starting from: "libclang: crash detected during parsing: " repeats for every file from my project.

The settings of project wasn't changed since last running of kdevelop and are following:
* Language Support -> Compilers (tab)
  - table with tree view (branch: Auto-detected): Clang, GCC
  - combo: "Compiler for path": Clang
  - C/C++ parser: Predefined profile: c++11
* CMake
Variable: CMAKE_MAKE_PROGRAM points to ninja  (here was make)
Variable: QT_QMAKE_EXECUTABLE is not set   (this variable was set)

I noticed that after run of KDevelop "Ninja" was set in "Default generator", despite before (using previous build of kdevelop from begin of December) I have here "Unix Makefiles". I mean option in:
Configure kdevelop -> CMake -> Configure global CMake setting -> Default generator: "Ninja"

I set it to my previous value, so: "Unix Makefiles", closed kdevelop, removed "build" directory from project, removed kdevduchain cache and run KDevelop again. Thanks that semantic syntax highlighting back.

It seems, and I'm not sure why, Ninja is default option for "Default generator". I have installed ninja, but didn't use it in my project.

Reproducible: Always


Actual Results:  
ninja is chose as "Default generator" whereas project use make (cmake)


Expected Results:  
In my opinion ninja should not be set as "Default generator" where in configuration file is set cmake
My configuration in "qtcmd2.kdev4" file
[Project]
Name=qtcmd2
Manager=KDevCMakeManager

kdevplatform and kdevelop built at 2016.01.01 (branch 5.0)
Comment 1 Milian Wolff 2016-02-21 13:23:10 UTC
Hey Piotr,

do you still get this crash all the time? Or is this issue resolved now? If not, we should try to find a reason for the crash... I haven't seen this - definitely not for all files in a project.
Comment 2 Piotr Mierzwinski 2016-02-29 00:21:42 UTC
I tested KDevelop and KDevplatform cloned at February 28th, 2016 after 10pm (branch 5.0).
Before run of newly built KDevelop I cleaned kdevduchain cache.
Settings in this test:
Configure KDevelop -> CMake
* "Default generator" = "Unix Makefiles"
Project configuration:
* CMake Variable: CMAKE_MAKE_PROGRAM points to "/usr/bin/make"

I noticed crashes only for files located in "build/CMakeFiles" (check attachment). Second crashing thing are files in C used in my project. 
Below please find part of output produced by KDevelop during running:

libclang: crash detected during parsing: {
  'source_filename' : '/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/build/CMakeFiles/3.2.2/CompilerIdCXX/CMakeCXXCompilerId.cpp'
  'command_line_args' : ['-ferror-limit=100', '-fspell-checking', '-Wdocumentation', '-Wunused-parameter', '-Wunreachable-code', '-Wall', '-std=c++11', '-nostdinc', '-nostdinc++', '-xc++', '-isystem', '/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/share/kdevclangsupport/wrappedQtHeaders', '-isystem', '/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/share/kdevclangsupport/wrappedQtHeaders/QtCore', '-include/usr/include/qt4/Qt/QtCore', '-include/usr/include/qt4/Qt/QtGui', '-include/usr/include/qt4/Qt/QtNetwork', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/include/c++/5', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/include/x86_64-linux-gnu/c++/5', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/include/c++/5/backward', '-isystem/usr/local/include', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/lib/llvm-3.6/lib/clang/3.6.2/include', '-isystem/usr/include/x86_64-linux-gnu', '-isystem/usr/include', '-imacros', '/tmp/kdevelop.yJ4066'],
  'unsaved_files' : [],
  'options' : 45,
}
kdevelop(4066)/(default) unknown: clang_parseTranslationUnit2 return with error code 2
kdevelop(4066)/(default) unknown:   (start KDevelop with `KDEV_CLANG_DISPLAY_DIAGS=1 kdevelop` to see more diagnostics)
kdevelop(4066)/(default) unknown: Failed to parse translation unit: "/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/build/CMakeFiles/3.2.2/CompilerIdCXX/CMakeCXXCompilerId.cpp"
libclang: crash detected during parsing: {
  'source_filename' : '/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/libs/xdgmime/xdgmime.c'
  'command_line_args' : ['-ferror-limit=100', '-fspell-checking', '-Wdocumentation', '-Wunused-parameter', '-Wunreachable-code', '-Wall', '-std=c++11', '-nostdinc', '-nostdinc++', '-xc++', '-isystem', '/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/share/kdevclangsupport/wrappedQtHeaders', '-isystem', '/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/share/kdevclangsupport/wrappedQtHeaders/QtCore', '-include/usr/include/qt4/Qt/QtCore', '-include/usr/include/qt4/Qt/QtGui', '-include/usr/include/qt4/Qt/QtNetwork', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/include/c++/5', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/include/x86_64-linux-gnu/c++/5', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/include/c++/5/backward', '-isystem/usr/local/include', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/lib/llvm-3.6/lib/clang/3.6.2/include', '-isystem/usr/include/x86_64-linux-gnu', '-isystem/usr/include', '-imacros', '/tmp/kdevelop.yJ4066'],
  'unsaved_files' : [],
  'options' : 45,
}
kdevelop(4066)/(default) unknown: clang_parseTranslationUnit2 return with error code 2
kdevelop(4066)/(default) unknown:   (start KDevelop with `KDEV_CLANG_DISPLAY_DIAGS=1 kdevelop` to see more diagnostics)
kdevelop(4066)/(default) unknown: Failed to parse translation unit: "/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/libs/xdgmime/xdgmime.c"
libclang: crash detected during parsing: {
  'source_filename' : '/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/libs/xdgmime/xdgmimeparent.c'
  'command_line_args' : ['-ferror-limit=100', '-fspell-checking', '-Wdocumentation', '-Wunused-parameter', '-Wunreachable-code', '-Wall', '-std=c++11', '-nostdinc', '-nostdinc++', '-xc++', '-isystem', '/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/share/kdevclangsupport/wrappedQtHeaders', '-isystem', '/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/share/kdevclangsupport/wrappedQtHeaders/QtCore', '-include/usr/include/qt4/Qt/QtCore', '-include/usr/include/qt4/Qt/QtGui', '-include/usr/include/qt4/Qt/QtNetwork', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/include/c++/5', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/include/x86_64-linux-gnu/c++/5', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/include/c++/5/backward', '-isystem/usr/local/include', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/lib/llvm-3.6/lib/clang/3.6.2/include', '-isystem/usr/include/x86_64-linux-gnu', '-isystem/usr/include', '-imacros', '/tmp/kdevelop.xX4066'],
  'unsaved_files' : [],
  'options' : 45,
}
kdevelop(4066)/(default) unknown: clang_parseTranslationUnit2 return with error code 2
kdevelop(4066)/(default) unknown:   (start KDevelop with `KDEV_CLANG_DISPLAY_DIAGS=1 kdevelop` to see more diagnostics)
kdevelop(4066)/(default) unknown: Failed to parse translation unit: "/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/libs/xdgmime/xdgmimeparent.c"

If you need more details I can run KDevelop with exported flag: KDEV_CLANG_DISPLAY_DIAGS=1

BTW.
Default setting (after very first start of KDevelop) for Configure KDevelop -> CMake is Ninja as "Default generator" whereas project use make (cmake) - as I mentioned in previous post.
Comment 3 Piotr Mierzwinski 2016-02-29 00:23:11 UTC
Created attachment 97600 [details]
kdevelop_libclang_crashes from 2016-02-29
Comment 4 Milian Wolff 2016-02-29 10:49:43 UTC
can you please export `KDEV_CLANG_DISPLAY_DIAGS=1` before running kdevelop and reproduce it again?

Also, what do these files contain:

/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/libs/xdgmime/xdgmime.c
/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/libs/xdgmime/xdgmimeparent.c

are they valid, i.e. do they exist? are they well-formed?
Comment 5 Piotr Mierzwinski 2016-02-29 19:18:14 UTC
Created attachment 97611 [details]
kdevelop_libclang_crashes_20160229 KDEV_CLANG_DISPLAY_DIAGS=1
Comment 6 Piotr Mierzwinski 2016-02-29 19:23:41 UTC
Every C files exist, are valid, well-formed and are used in the project. I build from them dynamic library and link with main binary. All of them coming from: git://anongit.freedesktop.org/xdg/xdgmime
Comment 7 Piotr Mierzwinski 2016-03-01 00:39:04 UTC
Some kind of proof (existing the C files):
$ ls -l /media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/libs/xdgmime/xdgmime.c
-rw-rw-r-- 1 piotrek piotrek 21203 lis 24 17:23 /media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/libs/xdgmime/xdgmime.c
$ ls -l /media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/libs/xdgmime/xdgmimeparent.c
-rw-rw-r-- 1 piotrek piotrek 4812 lis 24 17:23 /media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/libs/xdgmime/xdgmimeparent.c
$
$ ls -l /media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/build/libs/xdgmime/CMakeFiles/qtcmd2xdgmime.dir/xdgmime.c.o
-rw-rw-r-- 1 piotrek piotrek 40688 lut 29 00:40 /media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/build/libs/xdgmime/CMakeFiles/qtcmd2xdgmime.dir/xdgmime.c.o
$ ls -l /media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/build/libs/xdgmime/CMakeFiles/qtcmd2xdgmime.dir/xdgmimeparent.c.o
-rw-rw-r-- 1 piotrek piotrek 11112 lut 29 00:40 /media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/build/libs/xdgmime/CMakeFiles/qtcmd2xdgmime.dir/xdgmimeparent.c.o

And one more thing. When you open attached text file you will notice that on end are errors referring to not existing files. For this please check bug report: Bug 359942