MaskRay / ccls

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

TypeCorrectionConsumer::getNextCorrection crash with clang 11 #726

Open phush0 opened 3 years ago

phush0 commented 3 years ago

Observed behavior

Crash since Manjaro updated to clang 11 after commit f5bcd1dbdd6743df7537de73b2372abc98918982 will lead to frequent crashes on header change reindex

coc-config

    "ccls": {
      "command": "ccls",
      "filetypes": ["c", "cpp", "cuda", "objc", "objcpp"],
      "rootPatterns": [".ccls-root", "compile_commands.json", ".exvim*", ".git/"],
      "initializationOptions": {
        "cache": {
          "directory": ".ccls-cache",
          "retainInMemory": 2
        },
        "request": {
            "timeout": 20000
        },
        "client": {
          "snippetSupport": true
        },
        "highlight": { 
            "lsRanges" : true 
        },
        "index":{
            "trackDepenency": 2,
            "multiversion": 1,
            "onChange": false
        },
        "diagnostics": {
            "onChange": 1000,
            "onOpen": 0,
            "onSave": 0
        },
        "completion": {
            "detailedLabel": true
        }
      }

Expected behavior

Steps to reproduce

Change header e.g. config.h included in all source files. dump.txt

System information

MaskRay commented 3 years ago

As you can see from the stack trace, the crash happenedin TypeCorrectionConsumer::getNextCorrection, which is likely a Clang issue. Without more information it is difficult to troubleshoot.

Can you build a debug Clang and attach ccls with a debugger? You can get more information when the crash happens.

thestr4ng3r commented 3 years ago

I am not exactly sure if it is the same issue but I get very similar segfaults with clang 11 on Arch and ccls 2ad71f1058cb8079d7a78d35b2dc1af4e282881d:

...
#20909 0x00007f2c712b5379 in ?? () from /usr/lib/libclang-cpp.so.11
#20910 0x00007f2c712b6e5f in clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*, clang::VarDecl*, bool, llvm::function_ref<clang::ActionResult<clang::Expr*, true> (clang::Expr*)>) () from /usr/lib/libclang-cpp.so.11
#20911 0x00007f2c7120e72e in clang::Sema::BuildResolvedCallExpr(clang::Expr*, clang::NamedDecl*, clang::SourceLocation, llvm::ArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, clang::CallExpr::ADLCallKind) () from /usr/lib/libclang-cpp.so.11
#20912 0x00007f2c7120fae1 in clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool) () from /usr/lib/libclang-cpp.so.11
#20913 0x00007f2c712110de in clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) () from /usr/lib/libclang-cpp.so.11
#20914 0x00007f2c712c90b4 in ?? () from /usr/lib/libclang-cpp.so.11
#20915 0x00007f2c712b5379 in ?? () from /usr/lib/libclang-cpp.so.11
#20916 0x00007f2c712b6e5f in clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*, clang::VarDecl*, bool, llvm::function_ref<clang::ActionResult<clang::Expr*, true> (clang::Expr*)>) () from /usr/lib/libclang-cpp.so.11
#20917 0x00007f2c7120e72e in clang::Sema::BuildResolvedCallExpr(clang::Expr*, clang::NamedDecl*, clang::SourceLocation, llvm::ArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, clang::CallExpr::ADLCallKind) () from /usr/lib/libclang-cpp.so.11
#20918 0x00007f2c7120fae1 in clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool) () from /usr/lib/libclang-cpp.so.11
#20919 0x00007f2c712110de in clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) () from /usr/lib/libclang-cpp.so.11
#20920 0x00007f2c712c90b4 in ?? () from /usr/lib/libclang-cpp.so.11
#20921 0x00007f2c712b5379 in ?? () from /usr/lib/libclang-cpp.so.11
#20922 0x00007f2c712b6e5f in clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*, clang::VarDecl*, bool, llvm::function_ref<clang::ActionResult<clang::Expr*, true> (clang::Expr*)>) () from /usr/lib/libclang-cpp.so.11
#20923 0x00007f2c7120e72e in clang::Sema::BuildResolvedCallExpr(clang::Expr*, clang::NamedDecl*, clang::SourceLocation, llvm::ArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, clang::CallExpr::ADLCallKind) () from /usr/lib/libclang-cpp.so.11
#20924 0x00007f2c7120fae1 in clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool) () from /usr/lib/libclang-cpp.so.11
#20925 0x00007f2c712110de in clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) () from /usr/lib/libclang-cpp.so.11
#20926 0x00007f2c712c90b4 in ?? () from /usr/lib/libclang-cpp.so.11
#20927 0x00007f2c712b5379 in ?? () from /usr/lib/libclang-cpp.so.11
#20928 0x00007f2c712b6e5f in clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*, clang::VarDecl*, bool, llvm::function_ref<clang::ActionResult<clang::Expr*, true> (clang::Expr*)>) () from /usr/lib/libclang-cpp.so.11
#20929 0x00007f2c7120e72e in clang::Sema::BuildResolvedCallExpr(clang::Expr*, clang::NamedDecl*, clang::SourceLocation, llvm::ArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, clang::CallExpr::ADLCallKind) () from /usr/lib/libclang-cpp.so.11
#20930 0x00007f2c7120fae1 in clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool) () from /usr/lib/libclang-cpp.so.11
#20931 0x00007f2c712110de in clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) () from /usr/lib/libclang-cpp.so.11
#20932 0x00007f2c712c90b4 in ?? () from /usr/lib/libclang-cpp.so.11
#20933 0x00007f2c712b5379 in ?? () from /usr/lib/libclang-cpp.so.11
#20934 0x00007f2c712b6e5f in clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*, clang::VarDecl*, bool, llvm::function_ref<clang::ActionResult<clang::Expr*, true> (clang::Expr*)>) () from /usr/lib/libclang-cpp.so.11
#20935 0x00007f2c7120e72e in clang::Sema::BuildResolvedCallExpr(clang::Expr*, clang::NamedDecl*, clang::SourceLocation, llvm::ArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, clang::CallExpr::ADLCallKind) () from /usr/lib/libclang-cpp.so.11
#20936 0x00007f2c7120fae1 in clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool) () from /usr/lib/libclang-cpp.so.11
#20937 0x00007f2c712110de in clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) () from /usr/lib/libclang-cpp.so.11
#20938 0x00007f2c7082e582 in clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) () from /usr/lib/libclang-cpp.so.11
#20939 0x00007f2c70827042 in clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) () from /usr/lib/libclang-cpp.so.11
#20940 0x00007f2c7082a1e8 in clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) () from /usr/lib/libclang-cpp.so.11
#20941 0x00007f2c7082c796 in clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) () from /usr/lib/libclang-cpp.so.11
#20942 0x00007f2c7082d3fa in clang::Parser::ParseExpression(clang::Parser::TypeCastState) () from /usr/lib/libclang-cpp.so.11
#20943 0x00007f2c7088900e in clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) () from /usr/lib/libclang-cpp.so.11
#20944 0x00007f2c70886b74 in clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) () from /usr/lib/libclang-cpp.so.11
#20945 0x00007f2c708881ce in clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) () from /usr/lib/libclang-cpp.so.11
#20946 0x00007f2c7088b75b in clang::Parser::ParseCompoundStatementBody(bool) () from /usr/lib/libclang-cpp.so.11
#20947 0x00007f2c7088e39c in clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) () from /usr/lib/libclang-cpp.so.11
#20948 0x00007f2c708ae675 in clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) () from /usr/lib/libclang-cpp.so.11
#20949 0x00007f2c70806431 in clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) () from /usr/lib/libclang-cpp.so.11
#20950 0x00007f2c708a8826 in ?? () from /usr/lib/libclang-cpp.so.11
#20951 0x00007f2c708b08dc in clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) () from /usr/lib/libclang-cpp.so.11
#20952 0x00007f2c708b16a9 in clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool) () from /usr/lib/libclang-cpp.so.11
#20953 0x00007f2c707e1caa in clang::ParseAST(clang::Sema&, bool, bool) () from /usr/lib/libclang-cpp.so.11
#20954 0x00007f2c72166539 in clang::FrontendAction::Execute() () from /usr/lib/libclang-cpp.so.11
#20955 0x000055c4f79e721a in ccls::(anonymous namespace)::parse (clang=@0x7f2c3000ea20: <incomplete type>) at ../src/sema_manager.cc:333
#20956 0x000055c4f79e9874 in ccls::(anonymous namespace)::diagnosticMain (manager_=0x7ffc5dcc6fe0) at ../src/sema_manager.cc:593
#20957 0x00007f2c6a0ce3e9 in start_thread () from /usr/lib/libpthread.so.0
#20958 0x00007f2c69ffa293 in clone () from /usr/lib/libc.so.6

It just recurses infinitely above that. Ping me any time if you need more info.