MaskRay / ccls

C/C++/ObjC language server supporting cross references, hierarchies, completion and semantic highlighting
Apache License 2.0
3.72k stars 254 forks source link

ccls crashes while reindexing due to corrupted cache files #923

Open phord opened 1 year ago

phord commented 1 year ago

Observed behavior

ccls was crashing consistently while reindexing my project. It seemed to crash about the same place each time, but I didn't check this closely.

The crashing stopped when I deleted my ccls_cache files and reindexed from a clean slate. I'm sorry now I didn't save the (presumably corrupted) cache files that caused the failure. I did manage to save a stacktrace, though.

#0 0x00007f059a67cc3f llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x977c3f)
 #1 0x00007f059a67aed2 llvm::sys::RunSignalHandlers() (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x975ed2)
 #2 0x00007f059a67d205 (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x978205)
 #3 0x00007f0599500980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #4 0x000055bdd868010a ccls::BinaryReader::varInt() (/usr/local/bin/ccls+0x3f710a)
 #5 0x000055bdd867b909 ccls::reflect(ccls::BinaryReader&, short&) (/usr/local/bin/ccls+0x3f2909)
 #6 0x000055bdd860bf51 ccls::reflect(ccls::BinaryReader&, ccls::Use&) (/usr/local/bin/ccls+0x382f51)
 #7 0x000055bdd86832a4 void ccls::reflect<ccls::Use>(ccls::BinaryReader&, std::vector<ccls::Use, std::allocator<ccls::Use> >&) (/usr/local/bin/ccls+0x3fa2a4)
 #8 0x000055bdd8686d49 void ccls::reflect<ccls::IndexVar>(ccls::BinaryReader&, std::unordered_map<unsigned long, ccls::IndexVar, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<std::pair<unsigned long const, ccls::IndexVar> > >&) (/usr/local/bin/ccls+0x3fdd49)
 #9 0x000055bdd86872b1 void ccls::reflect1<ccls::BinaryReader>(ccls::BinaryReader&, ccls::IndexFile&) (/usr/local/bin/ccls+0x3fe2b1)
#10 0x000055bdd867eaba ccls::deserialize(ccls::SerializeFormat, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::optional<int>) (/usr/local/bin/ccls+0x3f5aba)
#11 0x000055bdd86337ce ccls::pipeline::(anonymous namespace)::rawCacheLoad(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (/usr/local/bin/ccls+0x3aa7ce)
#12 0x000055bdd8635aba ccls::pipeline::(anonymous namespace)::indexer_Parse(ccls::SemaManager*, ccls::WorkingFiles*, ccls::Project*, ccls::VFS*, ccls::GroupMatch const&) (/usr/local/bin/ccls+0x3acaba)
#13 0x000055bdd8638244 ccls::pipeline::indexer_Main(ccls::SemaManager*, ccls::VFS*, ccls::Project*, ccls::WorkingFiles*) (/usr/local/bin/ccls+0x3af244)
#14 0x000055bdd86db691 ccls::(anonymous namespace)::indexer(void*) (/usr/local/bin/ccls+0x452691)
#15 0x00007f05994f56db start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76db)
#16 0x00007f059921e61f clone /build/glibc-CVJwZb/glibc-2.27/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97:0

Expected behavior

Not crash, even if bad cache files are present.

System information