Andersbakken / rtags

A client/server indexer for c/c++/objc[++] with integration for Emacs based on clang.
http://www.rtags.net
GNU General Public License v3.0
1.83k stars 252 forks source link

Clang seems to have problems finding c++ related headers, rdm crashes #1198

Open tuvok opened 6 years ago

tuvok commented 6 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Clone repo: https://github.com/tuvok/spacebrowser/tree/passwordManager
  2. Use cmake to generate compile_commands.json and load them with rc -J
  3. Open PasswordManager.cpp with emacs, somewhere in one of the functions write "gpg." + company-complete
  4. No useful completions show up and rdm is crashed

Expected behavior rdm should provide completions without crashing

Screenshots/Backtrace When I start rdm without additional options, this is the output:

tuvok@vetar ~ $ rdm
Running with 8 jobs, using args: -ferror-limit=50 -Wall -fspell-checking -Wno-unknown-warning-option
Includepaths: "-isystem" /usr/lib/clang/5.0.1/include/
Restoring /home/tuvok/src/browser/ ........
/usr/local/bin/rc -m --elisp
/usr/local/bin/rc --current-file=/home/tuvok/src/browser/PasswordManager.cpp -b --unsaved-file=/home/tuvok/src/browser/PasswordManager.cpp:4846 -z --verify-version=125 --code-complete-at /home/tuvok/src/browser/PasswordManager.cpp:138:5: --synchronous-completions --elisp --code-complete-prefix=
/usr/lib/gcc/x86_64-pc-linux-gnu/6.4.0/include/g++-v6/cstddef:50:10: fatal error: 'stddef.h' file not found
/home/tuvok/src/browser/PasswordManager.cpp:14:21: error: cannot initialize object parameter of type 'QIODevice' with an expression of type 'QFile'
/home/tuvok/src/browser/PasswordManager.cpp:18:18: error: cannot initialize object parameter of type 'QIODevice' with an expression of type 'QFile'
/home/tuvok/src/browser/PasswordManager.cpp:37:15: error: invalid operands to binary expression ('std::ostream' (aka 'int') and 'const char *')
/home/tuvok/src/browser/PasswordManager.cpp:48:19: error: invalid operands to binary expression ('std::ostream' (aka 'int') and 'const char *')
/home/tuvok/src/browser/PasswordManager.cpp:92:19: error: invalid operands to binary expression ('std::ostream' (aka 'int') and 'const char *')
/home/tuvok/src/browser/PasswordManager.cpp:93:19: error: invalid operands to binary expression ('std::ostream' (aka 'int') and 'const char *')
/home/tuvok/src/browser/PasswordManager.cpp:94:19: error: invalid operands to binary expression ('std::ostream' (aka 'int') and 'const char *')
/home/tuvok/src/browser/PasswordManager.cpp:95:19: error: invalid operands to binary expression ('std::ostream' (aka 'int') and 'const char *')
/home/tuvok/src/browser/PasswordManager.cpp:137:16: error: member function 'createContext' not viable: 'this' argument has type 'const gnupgpp::GnupgPP', but function is not marked const
/home/tuvok/src/browser/gnupgpp/GnupgPP.h:15:25: note: 'createContext' declared here
/home/tuvok/src/browser/PasswordManager.cpp:140:15: error: invalid operands to binary expression ('std::ostream' (aka 'int') and 'const char *')
/home/tuvok/src/browser/PasswordManager.cpp:148:19: error: invalid operands to binary expression ('std::ostream' (aka 'int') and 'const char *')
/home/tuvok/src/browser/PasswordManager.cpp:149:19: error: invalid operands to binary expression ('std::ostream' (aka 'int') and 'const char *')
/home/tuvok/src/browser/PasswordManager.cpp:150:19: error: invalid operands to binary expression ('std::ostream' (aka 'int') and 'const char *')
/home/tuvok/src/browser/PasswordManager.cpp:153:23: error: invalid operands to binary expression ('std::ostream' (aka 'int') and 'const char *')
/home/tuvok/src/browser/PasswordManager.cpp:154:23: error: invalid operands to binary expression ('std::ostream' (aka 'int') and 'const char *')
/home/tuvok/src/browser/PasswordManager.cpp:155:23: error: invalid operands to binary expression ('std::ostream' (aka 'int') and 'const char *')
/home/tuvok/src/browser/PasswordManager.cpp:156:23: error: invalid operands to binary expression ('std::ostream' (aka 'int') and 'const char *')
/home/tuvok/src/browser/PasswordManager.cpp:158:19: error: invalid operands to binary expression ('std::ostream' (aka 'int') and 'const char *')
/home/tuvok/src/browser/PasswordManager.cpp:165:23: error: invalid operands to binary expression ('std::ostream' (aka 'int') and 'const char *')
fatal error: too many errors emitted, stopping now [-ferror-limit=]
Caught signal 11
rdm(+0x6146f)[0x55e32c88146f]
/lib64/libpthread.so.0(+0x14230)[0x7ff312cac230]
/usr/lib64/llvm/5/lib64/../lib64/../lib64/libclangSerialization.so.5(_ZN5clang9ASTReader13ReadSLocEntryEi+0x12f)[0x7ff30b5c6faf]
/usr/lib64/llvm/5/lib64/../lib64/libclangBasic.so.5(_ZNK5clang13SourceManager13loadSLocEntryEjPb+0x20)[0x7ff31102d790]
/usr/lib64/llvm/5/lib64/../lib64/libclangBasic.so.5(_ZNK5clang13SourceManager15getFileIDLoadedEj+0x18f)[0x7ff31102e2cf]
/usr/lib64/llvm/5/lib64/../lib64/libclangBasic.so.5(_ZNK5clang13SourceManager13getFileIDSlowEj+0x15)[0x7ff31102e545]
/usr/lib64/llvm/5/lib64/libclang.so.5(clang_getFileLocation+0x262)[0x7ff3133165b2]
rdm(_ZN5RTags19DiagnosticsProvider8diagnoseEv+0x2e3)[0x55e32c895083]
rdm(_ZN16CompletionThread18processDiagnosticsEPKNS_7RequestEP21CXCodeCompleteResultsP21CXTranslationUnitImpl+0x5aa)[0x55e32c98d21a]
rdm(_ZN16CompletionThread7processEPNS_7RequestE+0x210b)[0x55e32c9917ab]
rdm(_ZN16CompletionThread3runEv+0x1b0e)[0x55e32c99492e]
rdm(_ZN6Thread10localStartEPv+0x25)[0x55e32c9432f5]
/lib64/libpthread.so.0(+0x78da)[0x7ff312c9f8da]
/lib64/libc.so.6(clone+0x3f)[0x7ff311a1612f]

If I start rdm with additional include paths, the output is a bit different, but it still crashes:

tuvok@vetar ~ $ rdm -s /usr/lib64/gcc/x86_64-pc-linux-gnu/6.4.0/include/g++-v6/ -s /usr/lib64/gcc/x86_64-pc-linux-gnu/6.4.0/include/ -s /usr/include/
Running with 8 jobs, using args: -ferror-limit=50 -Wall -fspell-checking -Wno-unknown-warning-option
Includepaths: "-isystem" /usr/lib64/gcc/x86_64-pc-linux-gnu/6.4.0/include/g++-v6/ "-isystem" /usr/lib64/gcc/x86_64-pc-linux-gnu/6.4.0/include/ "-isystem" /usr/include/ "-isystem" /usr/lib/clang/5.0.1/include/
Restoring /home/tuvok/src/browser/ ........
[100%] 1/1 13:19:01 ~/src/browser/PasswordManager.cpp in 931ms. (226 syms, 165 symNames, 11 includes, 2 of 278 files, symbols: 311 of 14769, 15366 cursors, 133932 bytes written, 1 queried 0ms) (896/29/1ms) (dirty). (priority 1)
Jobs took 0.98s. We're using 9mb of memory.
Output from /home/tuvok/src/browser/PasswordManager.cpp:
handleInclude failed (nil) inclusion directive include limits.h /usr/include/limits.h:124:1

/usr/local/bin/rc --current-file=/home/tuvok/src/browser/PasswordManager.cpp -b --unsaved-file=/home/tuvok/src/browser/PasswordManager.cpp:4845 -z --verify-version=125 --code-complete-at /home/tuvok/src/browser/PasswordManager.cpp:145:1: --synchronous-completions --elisp --code-complete-prefix=gpg
/usr/local/bin/rc -m --elisp
/usr/local/bin/rc --current-file=/home/tuvok/src/browser/PasswordManager.cpp -b --unsaved-file=/home/tuvok/src/browser/PasswordManager.cpp:4846 -z --verify-version=125 --code-complete-at /home/tuvok/src/browser/PasswordManager.cpp:145:5: --synchronous-completions --elisp --code-complete-prefix=
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/home/tuvok/src/browser/PasswordManager.cpp:14:21: error: cannot initialize object parameter of type 'QIODevice' with an expression of type 'QFile'
/home/tuvok/src/browser/PasswordManager.cpp:18:18: error: cannot initialize object parameter of type 'QIODevice' with an expression of type 'QFile'
/home/tuvok/src/browser/PasswordManager.cpp:137:16: error: member function 'createContext' not viable: 'this' argument has type 'const gnupgpp::GnupgPP', but function is not marked const
/home/tuvok/src/browser/gnupgpp/GnupgPP.h:15:25: note: 'createContext' declared here
Caught signal 11
rdm(+0x6146f)[0x55a830c2d46f]
/lib64/libpthread.so.0(+0x14230)[0x7fc220e94230]
/usr/lib64/llvm/5/lib64/../lib64/../lib64/libclangSerialization.so.5(_ZN5clang9ASTReader13ReadSLocEntryEi+0x12f)[0x7fc2197aefaf]
/usr/lib64/llvm/5/lib64/../lib64/libclangBasic.so.5(_ZNK5clang13SourceManager13loadSLocEntryEjPb+0x20)[0x7fc21f215790]
/usr/lib64/llvm/5/lib64/../lib64/libclangBasic.so.5(_ZNK5clang13SourceManager15getFileIDLoadedEj+0x18f)[0x7fc21f2162cf]
/usr/lib64/llvm/5/lib64/../lib64/libclangBasic.so.5(_ZNK5clang13SourceManager13getFileIDSlowEj+0x15)[0x7fc21f216545]
/usr/lib64/llvm/5/lib64/libclang.so.5(clang_getFileLocation+0x262)[0x7fc2214fe5b2]
rdm(_ZN5RTags19DiagnosticsProvider8diagnoseEv+0x2e3)[0x55a830c41083]
rdm(_ZN16CompletionThread18processDiagnosticsEPKNS_7RequestEP21CXCodeCompleteResultsP21CXTranslationUnitImpl+0x5aa)[0x55a830d3921a]
rdm(_ZN16CompletionThread7processEPNS_7RequestE+0x210b)[0x55a830d3d7ab]
rdm(_ZN16CompletionThread3runEv+0x1b0e)[0x55a830d4092e]
rdm(_ZN6Thread10localStartEPv+0x25)[0x55a830cef2f5]
/lib64/libpthread.so.0(+0x78da)[0x7fc220e878da]
/lib64/libc.so.6(clone+0x3f)[0x7fc21fbfe12f]

Environment (please complete the following information):

I will gladly provide any additional info needed

Andersbakken commented 6 years ago

Sorry about the long delay.

I suppose this problem isn't really limited to spacebrowser.

I think this is related to your clang install and rtags' assumptions about where its central headers are supposed to be installed.

Are you building this clang yourself or getting it from gentoo's package system?

Can you try to let rtags build clang for you?

E.g.

cmake -DRTAGS_BUILD_CLANG=1 ...

There's some more info on this in the readme.

tuvok commented 6 years ago

I'm using clang from gentoo's package system. Is there a way to point rtags to the right headers directory? I'd prefer to use system installed clang if possible.