Closed hhaim closed 5 years ago
The issue happen even with this example:
#include <stdio.h>
class A {
public:
int a;
int b;
};
int main(){
A* a= new A();
a->b =12;
printf(" hello %d %d \n",a->a,a->b);
return (0);
}
Server CWD is /scratch/hhaim/cpp_test
14:42:38 ccls initialize.cc:274 I initialize in directory /scratch/hhaim/cpp_test with uri file:///scratch/hhaim/cpp_test
14:42:38 ccls initialize.cc:297 I initializationOptions: {"compilationDatabaseCommand":"","compilationDatabaseDirectory":"","cache":{"directory":"/scratch/hhaim/ccls_cache/","format":"binary","hierarchicalPath":false,"retainInMemory":2},"capabilities":{"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"}","moreTriggerCharacter":[]},"foldingRangeProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":true}}},"clang":{"excludeArgs":[],"extraArgs":[],"pathMappings":[],"resourceDir":""},"client":{"diagnosticsRelatedInformation":true,"hierarchicalDocumentSymbolSupport":true,"linkSupport":true,"snippetSupport":false},"codeLens":{"localVariables":false},"completion":{"caseSensitivity":2,"detailedLabel":false,"dropOldRequests":true,"duplicateOptional":false,"filterAndSort":true,"include":{"blacklist":[],"maxPathSize":37,"suffixWhitelist":[".h",".hpp",".hh",".inc",".h",".hpp",".hh"],"whitelist":[]},"maxNum":100},"diagnostics":{"blacklist":[],"onChange":1000,"onOpen":0,"onSave":0,"spellChecking":true,"whitelist":[]},"highlight":{"largeFileSize":2097152,"lsRanges":true,"blacklist":[],"whitelist":[]},"index":{"blacklist":[],"comments":2,"initialNoLinkage":false,"initialBlacklist":[],"initialWhitelist":[],"maxInitializerLines":15,"multiVersion":0,"multiVersionBlacklist":[],"multiVersionWhitelist":[],"name":{"suppressUnwrittenScope":false},"onChange":false,"parametersInDeclarations":true,"threads":0,"trackDependency":2,"whitelist":[]},"request":{"timeout":5000},"session":{"maxNum":10},"workspaceSymbol":{"caseSensitivity":1,"maxNum":1000,"sort":true},"xref":{"maxNum":2000}}
14:42:38 ccls initialize.cc:326 I use -resource-dir=/scratch/hhaim/llvm8/llvm/build/lib/clang/8.0.1
14:42:38 ccls initialize.cc:359 I workspace folder: /scratch/hhaim/cpp_test/
14:42:38 ccls initialize.cc:384 I start 24 indexers
14:42:38 ccls initialize.cc:392 I dispatch initial index requests
14:42:38 ccls pipeline.cc:485 I loaded project. Refresh semantic highlight for all working file.
14:42:38 indexer0 pipeline.cc:351 I parse /scratch/hhaim/cpp_test/main.cpp
14:42:38 preamble sema_manager.cc:744 I create session for /scratch/hhaim/cpp_test/main.cpp
*** Error in `/scratch/hhaim/ccls/Release/ccls': free(): invalid pointer: 0x00007fa290004bec ***
======= Backtrace: =========
/lib64/libc.so.6(+0x81489)[0x7fa2a5248489]
/scratch/hhaim/ccls/Release/ccls[0x40e9f8]
/scratch/hhaim/ccls/Release/ccls[0x5cd159]
/scratch/hhaim/ccls/Release/ccls[0x5bbd99]
/scratch/hhaim/ccls/Release/ccls[0x42017c]
/scratch/hhaim/ccls/Release/ccls[0x445d34]
/scratch/hhaim/ccls/Release/ccls[0x444504]
/scratch/hhaim/ccls/Release/ccls[0x4eaa37]
/lib64/libpthread.so.0(+0x7dd5)[0x7fa2a5e38dd5]
/lib64/libc.so.6(clone+0x6d)[0x7fa2a52c4ead]
======= Memory map: ========
/scratch/hhaim/ccls/Release/ccls[0x12e450f]
/scratch/hhaim/ccls/Release/ccls[0x12e2b72]
/scratch/hhaim/ccls/Release/ccls[0x12e4931]
/lib64/libpthread.so.0(+0xf5d0)[0x7fa2a5e405d0]
/scratch/hhaim/ccls/Release/ccls[0x40e8f2]
/scratch/hhaim/ccls/Release/ccls[0x5cd159]
/scratch/hhaim/ccls/Release/ccls[0x5bbd99]
/scratch/hhaim/ccls/Release/ccls[0x6367f0]
/scratch/hhaim/ccls/Release/ccls[0x48716c]
/lib64/libpthread.so.0(+0x7dd5)[0x7fa2a5e38dd5]
00400000-01823000 r-xp 00000000 fd:00 301702581 /scratch/hhaim/ccls/Release/ccls
01a23000-01b18000 r--p 01423000 fd:00 301702581 /scratch/hhaim/ccls/Release/ccls
01b18000-01b1f000 rw-p 01518000 fd:00 301702581 /scratch/hhaim/ccls/Release/ccls
01b1f000-01b27000 rw-p 00000000 00:00 0
033f6000-03428000 rw-p 00000000 00:00 0 [heap]
7fa224000000-7fa224021000 rw-p 00000000 00:00 0
7fa224021000-7fa228000000 ---p 00000000 00:00 0
7fa22c000000-7fa22c021000 rw-p 00000000 00:00 0
7fa22c021000-7fa230000000 ---p 00000000 00:00 0
7fa230000000-7fa230021000 rw-p 00000000 00:00 0
7fa230021000-7fa234000000 ---p 00000000 00:00 0
7fa234000000-7fa234021000 rw-p 00000000 00:00 0
7fa234021000-7fa238000000 ---p 00000000 00:00 0
7fa238000000-7fa238021000 rw-p 00000000 00:00 0
7fa238021000-7fa23c000000 ---p 00000000 00:00 0
7fa23c000000-7fa23c021000 rw-p 00000000 00:00 0
7fa23c021000-7fa240000000 ---p 00000000 00:00 0
7fa240000000-7fa240021000 rw-p 00000000 00:00 0
7fa240021000-7fa244000000 ---p 00000000 00:00 0
7fa244000000-7fa244021000 rw-p 00000000 00:00 0
7fa244021000-7fa248000000 ---p 00000000 00:00 0
7fa248000000-7fa248021000 rw-p 00000000 00:00 0
7fa248021000-7fa24c000000 ---p 00000000 00:00 0
7fa24c000000-7fa24c021000 rw-p 00000000 00:00 0
7fa24c021000-7fa250000000 ---p 00000000 00:00 0
7fa250000000-7fa250021000 rw-p 00000000 00:00 0
7fa250021000-7fa254000000 ---p 00000000 00:00 0
7fa254000000-7fa254021000 rw-p 00000000 00:00 0
7fa254021000-7fa258000000 ---p 00000000 00:00 0
7fa258000000-7fa258021000 rw-p 00000000 00:00 0
7fa258021000-7fa25c000000 ---p 00000000 00:00 0
7fa25c000000-7fa25c021000 rw-p 00000000 00:00 0
7fa25c021000-7fa260000000 ---p 00000000 00:00 0
7fa260000000-7fa260021000 rw-p 00000000 00:00 0
7fa260021000-7fa264000000 ---p 00000000 00:00 0
7fa264000000-7fa264021000 rw-p 00000000 00:00 0
7fa264021000-7fa268000000 ---p 00000000 00:00 0
7fa2697fb000-7fa2697fc000 ---p 00000000 0/lib64/libc.so.6(clone+0x6d)[0x7fa2a52c4ead]
0:00 0
7fa2697fc000-7fa269ffc000 rw-p 00000000 00:00 0 [stack:1715]
7fa269ffc000-7fa269ffd000 ---p 00000000 00:00 0
7fa269ffd000-7fa26a7fd000 rw-p 00000000 00:00 0 [stack:1714]
7fa26a7fd000-7fa26a7fe000 ---p 00000000 00:00 0
7fa26a7fe000-7fa26affe000 rw-p 00000000 00:00 0 [stack:1713]
7fa26affe000-7fa26afff000 ---p 00000000 00:00 0
7fa26afff000-7fa26b7ff000 rw-p 00000000 00:00 0 [stack:1712]
7fa26b7ff000-7fa26b800000 ---p 00000000 00:00 0
7fa26b800000-7fa26c000000 rw-p 00000000 00:00 0 [stack:1704]
7fa26c000000-7fa26c021000 rw-p 00000000 00:00 0
7fa26c021000-7fa270000000 ---p 00000000 00:00 0
7fa2707f9000-7fa2707fa000 ---p 00000000 00:00 0
7fa2707fa000-7fa270ffa000 rw-p 00000000 00:00 0 [stack:1711]
7fa270ffa000-7fa270ffb000 ---p 00000000 00:00 0
7fa270ffb000-7fa2717fb000 rw-p 00000000 00:00 0 [stack:1710]
7fa2717fb000-7fa2717fc000 ---p 00000000 00:00 0
7fa2717fc000-7fa271ffc000 rw-p 00000000 00:00 0 [stack:1709]
7fa271ffc000-7fa271ffd000 ---p 00000000 00:00 0
7fa271ffd000-7fa2727fd000 rw-p 00000000 00:00 0 [stack:1708]
7fa2727fd000-7fa2727fe000 ---p 00000000 00:00 0
7fa2727fe000-7fa272ffe000 rw-p 00000000 00:00 0 [stack:1707]
7fa272ffe000-7fa272fff000 ---p 00000000 00:00 0
7fa272fff000-7fa2737ff000 rw-p 00000000 00:00 0 [stack:1706]
7fa2737ff000-7fa273800000 ---p 00000000 00:00 0
7fa273800000-7fa274000000 rw-p 00000000 00:00 0 [stack:1705]
7fa274000000-7fa274021000 rw-p 00000000 00:00 0
7fa274021000-7fa278000000 ---p 00000000 00:00 0
7fa278000000-7fa278021000 rw-p 00000000 00:00 0
7fa278021000-7fa27c000000 ---p 00000000 00:00 0
7fa27c000000-7fa27c021000 rw-p 00000000 00:00 0
7fa27c021000-7fa280000000 ---p 00000000 00:00 0
7fa280000000-7fa280021000 rw-p 00000000 00:00 0
7fa280021000-7fa284000000 --ccls error (count undefined): undefined
ccls error (count undefined): undefined
ccls server connection was closed
[Error - 2:42:38 PM] Connection to server got closed. Server will not be restarted.
Moving to clang 8.0.1 does not solve the issue. I'm doing something wrong
this crash too
./ccls --version
ccls version 0.20190823-0-gd417597a
clang version 8.0.1 (https://github.com/llvm-mirror/clang.git 2e4c9c5fc864c2c432e4c262a67c42d824b265c6) (https://github.com/llvm-mirror/llvm.git ea28a67e47fd87c6b78597d90eba543bad4d7468)
The server has many threads. 80% is about 24 threads. Limiting it to one thread like this solves the problem
exec "/scratch/hhaim/ccls/Debug/ccls" "$@" -init='{"index": {"threads": 1}}'
Now I need to go back to llvm 90 to retest
Error in `/scratch/hhaim/ccls/Release/ccls': free(): invalid pointer: 0x00007fa290004bec
It is hard to tell what goes wrong with a Release build. Please try https://github.com/MaskRay/ccls/wiki/Debugging
@MaskRay thanks, I found the issue, it was my fault. ccls is brilliant, works much better than clangd 10, not sure why, if both are using the same clag index parser ??
The issue:
I enabled it in standalone mode and crashed so it was easier to debug
gdb --args ccls -index=/trex-core/ -v=1
bt
The crash pointed to clang library. It means something was wrong with my build. then I found this in your script (make -j 20 VERBOSE=1)
if(NOT CLANG_RESOURCE_DIR)
find_program(CLANG_EXECUTABLE clang)
if(NOT CLANG_EXECUTABLE)
message(FATAL_ERROR "clang executable not found.")
endif()
The clang path was different than the library location that I've build (I have many clang on this machine)
fixing this solve the issue.
-DCLANG_RESOURCE_DIR=[your llvm dir]
I'm glad that you've figured out the issue.
The clang path was different than the library location that I've build (I have many clang on this machine)
-DCLANG_RESOURCE_DIR=[your llvm dir]
couldn't be responsible for the crash - they are just ordinary header files. It is recommended to use clang with the matching resource directory but it usually does not matter much if the versions mismatch.
My intuition is that you had mismatched clang/llvm header files and clang/llvm libraries. The libLLVM*.a
or libclang*.a
were not from the same build, or the libraries were not built with the set of header files you used to build ccls. clang/llvm does not maintain a stable C++ ABI.
This is exactly what I had in mind. I did another change. I’ve compiled it with gcc 7.4 (both clang and CVLA) instead of a private clang++ compiler. Maybe the header was taken from the compiler (clang) instead of the lib private brach.
First thanks for doing that, still didn't find a c++ LSP that works I'm a user of vscode+clangd 10 LSP and I'm not happy so wanted to try out ccls. I have 5 min experience with ccls so forgive me if I missed something
I didn't manage to run it as a standalone mode
vscode configuration:
vscode - log
compile_commands.json
or.ccls
project can be found here https://github.com/cisco-system-traffic-generator/trex-core
(https://github.com/MaskRay/ccls/wiki/Project-Setup))
Reduce to A minimal set of
.c
.cc
.h
.hh
files that can still demonstrate the issue.Consider a screencast gif.
ccls version (
git describe --tags --long
):master 4711fd3 completion: don't reuse cache if the buffer line has changed
clang version:
CentOS Linux release 7.6.1810 (Core)
vscode latest