Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Objective-C++ Code triggers assertion failure #365

Closed
bc-lee opened this issue May 4, 2020 · 5 comments
Closed

Objective-C++ Code triggers assertion failure #365

bc-lee opened this issue May 4, 2020 · 5 comments

Comments

@bc-lee
Copy link

bc-lee commented May 4, 2020

Consider this Objective-C++ Code:

#import <Foundation/Foundation.h>

#include <memory>
#include <vector>

NS_ASSUME_NONNULL_BEGIN

@interface MyBuffer : NSObject
@end

@interface MyBuffer () {
  std::unique_ptr<std::vector<char>> data_;
}
@end

NS_ASSUME_NONNULL_END

@implementation MyBuffer

- (instancetype)initWithWidth:(size_t)size {
  if (self = [super init]) {
    data_.reset(new std::vector<char>(size));
  }
  return self;
}

@end

Logs

$ ninja check-clangd
[9/10] Running the Clangd regression tests
llvm-lit: /Users/leebc/src/llvm-project/build/bin/../../llvm/utils/lit/lit/llvm/config.py:343: note: using clang: /Users/leebc/src/llvm-project/build/bin/clang
FAIL: Clangd :: objc.test (793 of 793)
******************** TEST 'Clangd :: objc.test' FAILED ********************
Script:
--
: 'RUN: at line 2';   clangd -lit-test < /Users/leebc/src/llvm-project/clang-tools-extra/clangd/test/objc.test | FileCheck -strict-whitespace /Users/leebc/src/llvm-project/clang-tools-extra/clangd/test/objc.test
--
Exit Code: 1

Command Output (stderr):
--
I[04:22:41.552] clangd version 11.0.0 (https://github.com/llvm/llvm-project.git e737847b8fc36b6526ad6c7ceb65d0bd07358497)
I[04:22:41.553] PID: 32087
I[04:22:41.553] Working directory: /Users/leebc/src/llvm-project/build/tools/clang/tools/extra/clangd/test
I[04:22:41.553] argv[0]: clangd
I[04:22:41.553] argv[1]: -lit-test
I[04:22:41.553] Starting LSP over stdin/stdout
V[04:22:41.554] <<< {
  "id": 0,
  "jsonrpc": "2.0",
  "method": "initialize",
  "params": {
    "capabilities": {},
    "processId": 123,
    "rootPath": "clangd",
    "trace": "off"
  }
}

I[04:22:41.554] <-- initialize(0)
V[04:22:41.555] Invoking /usr/bin/xcrun to find clang installation
V[04:22:41.565] Invoking /usr/bin/xcrun to find clang installation
I[04:22:41.575] --> reply:initialize(0) 20 ms
V[04:22:41.575] >>> {
  "id": 0,
  "jsonrpc": "2.0",
  "result": {
    "capabilities": {
      "codeActionProvider": true,
      "completionProvider": {
        "allCommitCharacters": " \t()[]{}<>:;,+-/*%^&#?.=\"'|",
        "resolveProvider": false,
        "triggerCharacters": [
          ".",
          ">",
          ":"
        ]
      },
      "declarationProvider": true,
      "definitionProvider": true,
      "documentFormattingProvider": true,
      "documentHighlightProvider": true,
      "documentLinkProvider": {
        "resolveProvider": false
      },
      "documentOnTypeFormattingProvider": {
        "firstTriggerCharacter": "\n",
        "moreTriggerCharacter": []
      },
      "documentRangeFormattingProvider": true,
      "documentSymbolProvider": true,
      "executeCommandProvider": {
        "commands": [
          "clangd.applyFix",
          "clangd.applyTweak"
        ]
      },
      "hoverProvider": true,
      "referencesProvider": true,
      "renameProvider": true,
      "selectionRangeProvider": true,
      "semanticTokensProvider": {
        "documentProvider": {
          "edits": true
        },
        "legend": {
          "tokenModifiers": [],
          "tokenTypes": [
            "variable",
            "variable",
            "parameter",
            "function",
            "member",
            "function",
            "member",
            "variable",
            "class",
            "enum",
            "enumConstant",
            "type",
            "dependent",
            "dependent",
            "namespace",
            "typeParameter",
            "concept",
            "type",
            "macro",
            "comment"
          ]
        },
        "rangeProvider": false
      },
      "signatureHelpProvider": {
        "triggerCharacters": [
          "(",
          ","
        ]
      },
      "textDocumentSync": {
        "change": 2,
        "openClose": true,
        "save": true
      },
      "typeHierarchyProvider": true,
      "workspaceSymbolProvider": true
    },
    "serverInfo": {
      "name": "clangd",
      "version": "clangd version 11.0.0 (https://github.com/llvm/llvm-project.git e737847b8fc36b6526ad6c7ceb65d0bd07358497)"
    }
  }
}

V[04:22:41.575] <<< {
  "jsonrpc": "2.0",
  "method": "textDocument/didOpen",
  "params": {
    "textDocument": {
      "languageId": "objective-cpp",
      "text": "#import <Foundation/Foundation.h>\n#include <memory>\n#include <vector>\nNS_ASSUME_NONNULL_BEGIN\n@interface MyBuffer : NSObject\n@end\n@interface MyBuffer () {\n  std::unique_ptr<std::vector<char>> data_;\n}\n@end\nNS_ASSUME_NONNULL_END\n@implementation MyBuffer\n- (instancetype)initWithWidth:(size_t)size {\n  if (self = [super init]) {\n    data_.reset(new std::vector<char>(size));\n  }\n  return self;\n}\n@end\n",
      "uri": "test:///test.mm",
      "version": 1
    }
  }
}

I[04:22:41.575] <-- textDocument/didOpen
Error reading configuration from /clangd-test: directory doesn't exist.
I[04:22:41.576] Failed to find compilation database for /clangd-test/test.mm
I[04:22:41.577] ASTWorker building file /clangd-test/test.mm version 1 with command clangd fallback
[/clangd-test]
/Applications/Xcode11.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang /clangd-test/test.mm -fsyntax-only -resource-dir=/Users/leebc/src/llvm-project/build/lib/clang/11.0.0 -isysroot /Applications/Xcode11.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
I[04:22:41.577] Couldn't set working directory when creating compiler invocation.
V[04:22:41.583] Driver produced command: cc1 -cc1 -triple x86_64-apple-macosx10.15.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -fsyntax-only -disable-free -main-file-name test.mm -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=all -fno-rounding-math -munwind-tables -target-sdk-version=10.15.4 -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -target-linker-version 556.6 -resource-dir /Users/leebc/src/llvm-project/build/lib/clang/11.0.0 -isysroot /Applications/Xcode11.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -stdlib=libc++ -internal-isystem /Applications/Xcode11.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1 -internal-isystem /Applications/Xcode11.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1 -internal-isystem /Applications/Xcode11.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Users/leebc/src/llvm-project/build/lib/clang/11.0.0/include -internal-externc-isystem /Applications/Xcode11.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -fdeprecated-macro -fdebug-compilation-dir /Users/leebc/src/llvm-project/build/tools/clang/tools/extra/clangd/test -ferror-limit 19 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fobjc-runtime=macosx-10.15.0 -fobjc-exceptions -fcxx-exceptions -fexceptions -fmax-type-align=16 -x objective-c++ /clangd-test/test.mm
V[04:22:41.584] Building first preamble for /clangd-test/test.mm version 1
I[04:22:41.584] Couldn't set working directory when building the preamble.
V[04:23:12.077] indexed preamble AST for /clangd-test/test.mm version 1:
  symbol slab: 58097 symbols, 19848803 bytes
  ref slab: 0 symbols, 0 refs, 136 bytes
  relations slab: 421 relations, 8728 bytes
V[04:23:22.522] Build dynamic index for header symbols with estimated memory usage of 33098516 bytes
V[04:23:22.563] Built preamble of size 21918364 for file /clangd-test/test.mm version 1
I[04:23:22.564] Couldn't set working directory when building the preamble.
Assertion failed: (!StringRef(QName).startswith("::")), function printQualifiedName, file /Users/leebc/src/llvm-project/clang-tools-extra/clangd/AST.cpp, line 179.
/Users/leebc/src/llvm-project/clang-tools-extra/clangd/test/objc.test:8:10: error: CHECK: expected string not found in input
# CHECK: {"id":2,"jsonrpc":"2.0","result":
         ^
<stdin>:1:1: note: scanning from here
Content-Length: 2216
^
<stdin>:5:3: note: possible intended match here
  "jsonrpc": "2.0",
  ^

System information
Revision(git rev-parse --short HEAD): e737847b8fc
Operating system: MacOS 10.15

@hokein
Copy link
Contributor

hokein commented May 5, 2020

could you provide the content of llvm-project/clang-tools-extra/clangd/test/objc.test? The above messages indicate some errors already, e.g. Couldn't set working directory when creating compiler invocation..

just curious, you are running the clangd unittest, are you developing clangd? I think most clangd users just use clangd in an editor with a LSP plugin.

@bc-lee
Copy link
Author

bc-lee commented May 5, 2020

I also just a user of clangd and I just wanted to narrow down this issue. This is the first time for me to opening the LLVM/clang source code.

objc.test:

# REQUIRES: system-darwin
# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
---
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///test.mm","languageId":"objective-cpp","version":1,"text":"#import <Foundation/Foundation.h>\n#include <memory>\n#include <vector>\nNS_ASSUME_NONNULL_BEGIN\n@interface MyBuffer : NSObject\n@end\n@interface MyBuffer () {\n  std::unique_ptr<std::vector<char>> data_;\n}\n@end\nNS_ASSUME_NONNULL_END\n@implementation MyBuffer\n- (instancetype)initWithWidth:(size_t)size {\n  if (self = [super init]) {\n    data_.reset(new std::vector<char>(size));\n  }\n  return self;\n}\n@end\n"}}}
---
{"jsonrpc":"2.0","id":1,"method":"workspace/symbol","params":{"query":"data_"}}
# CHECK: {"id":2,"jsonrpc":"2.0","result":
--
{"jsonrpc":"2.0","id":2,"method":"shutdown"}
---
{"jsonrpc":"2.0","method":"exit"}

@hokein
Copy link
Contributor

hokein commented May 6, 2020

I see, thanks for offering the help!

The lit test might not mirror the real environment where you encountered the crash, I think the common practice for normal clangd users (if you see a crash) is gathering clangd stderr outputs in your editor, see https://clangd.llvm.org/troubleshooting.html#gathering-logs

btw, I didn't reproduce the crash with the above code on mac (with clangd 10), what I did:

  1. create a /tmp/new.mm and paste the code
  2. open /tmp/new.mm in vscode
  3. clangd works.

@bc-lee
Copy link
Author

bc-lee commented May 6, 2020

The original crash occurred from much complex code so I was trying to simplify code as much as I can.

After that, I've tested three cases:

  1. My build of master version ( e737847b8fc ) clangd.
  2. My build of 10.0.0 version ( d32170dbd5b ) clangd.
  3. Prebuilt 10.0.0 clangd acquired from homebrew.

1 and 2 have several custom options, most notably, assertions are enabled:

cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;libcxx;libcxxabi' -DLLVM_ENABLE_ASSERTIONS=True -DLLVM_CCACHE_BUILD=True -DCMAKE_INSTALL_PREFIX=$HOME/.local/llvm ../llvm
ninja install-clangd install-cxx-headers install-clang-resource-headers

From my tests using clangd plugin of VS Code, 1 and 2 (My builds) have triggered an assertion whereas 3 does not trigger any issue. It is weird.

I'll do retest using homebrew's build with original codes but it will take some time.

The log of test 2:

I[23:04:09.332] clangd version 10.0.0 (https://github.com/llvm/llvm-project.git d32170dbd5b0d54436537b6b75beaf44324e0c28)
I[23:04:09.332] PID: 22254
I[23:04:09.332] Working directory: /private/tmp/test
I[23:04:09.332] argv[0]: /Users/leebc/.local/llvm/bin/clangd
I[23:04:09.332] argv[1]: --log=verbose
I[23:04:09.332] Starting LSP over stdin/stdout
V[23:04:09.334] <<< {"id":0,"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dynamicRegistration":true,"isPreferredSupport":true},"codeLens":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"completion":{"completionItem":{"commitCharactersSupport":true,"deprecatedSupport":true,"documentationFormat":["markdown","plaintext"],"preselectSupport":true,"snippetSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},"contextSupport":true,"dynamicRegistration":true,"editsNearCursor":true},"declaration":{"dynamicRegistration":true,"linkSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"documentHighlight":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"documentSymbol":{"dynamicRegistration":true,"hierarchicalDocumentSymbolSupport":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"foldingRange":{"dynamicRegistration":true,"lineFoldingOnly":true,"rangeLimit":5000},"formatting":{"dynamicRegistration":true},"hover":{"contentFormat":["markdown","plaintext"],"dynamicRegistration":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"onTypeFormatting":{"dynamicRegistration":true},"publishDiagnostics":{"relatedInformation":true,"tagSupport":{"valueSet":[1,2]},"versionSupport":false},"rangeFormatting":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"selectionRange":{"dynamicRegistration":true},"semanticHighlightingCapabilities":{"semanticHighlighting":true},"signatureHelp":{"contextSupport":true,"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}}},"synchronization":{"didSave":true,"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true}},"window":{"workDoneProgress":true},"workspace":{"applyEdit":true,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"executeCommand":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"workspaceEdit":{"documentChanges":true,"failureHandling":"textOnlyTransactional","resourceOperations":["create","rename","delete"]},"workspaceFolders":true}},"clientInfo":{"name":"vscode","version":"1.44.2"},"initializationOptions":{"clangdFileStatus":true,"fallbackFlags":[]},"processId":22249,"rootPath":"/private/tmp/test","rootUri":"file:///private/tmp/test","trace":"off","workspaceFolders":[{"name":"test","uri":"file:///private/tmp/test"}]}}

I[23:04:09.334] <-- initialize(0)
V[23:04:09.336] Invoking /usr/bin/xcrun to find clang installation
V[23:04:09.356] Invoking /usr/bin/xcrun to find clang installation
I[23:04:09.367] --> reply:initialize(0) 32 ms
V[23:04:09.367] >>> {"id":0,"jsonrpc":"2.0","result":{"capabilities":{"codeActionProvider":{"codeActionKinds":["quickfix","refactor","info"]},"completionProvider":{"resolveProvider":false,"triggerCharacters":[".",">",":"]},"declarationProvider":true,"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentLinkProvider":{"resolveProvider":false},"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"\n","moreTriggerCharacter":[]},"documentRangeFormattingProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]},"hoverProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"semanticHighlighting":{"scopes":[["variable.other.cpp"],["variable.other.local.cpp"],["variable.parameter.cpp"],["entity.name.function.cpp"],["entity.name.function.method.cpp"],["entity.name.function.method.static.cpp"],["variable.other.field.cpp"],["variable.other.field.static.cpp"],["entity.name.type.class.cpp"],["entity.name.type.enum.cpp"],["variable.other.enummember.cpp"],["entity.name.type.typedef.cpp"],["entity.name.type.dependent.cpp"],["entity.name.other.dependent.cpp"],["entity.name.namespace.cpp"],["entity.name.type.template.cpp"],["storage.type.primitive.cpp"],["entity.name.function.preprocessor.cpp"],["meta.disabled"]]},"signatureHelpProvider":{"triggerCharacters":["(",","]},"textDocumentSync":2,"typeHierarchyProvider":true,"workspaceSymbolProvider":true}}}

V[23:04:09.407] <<< {"jsonrpc":"2.0","method":"initialized","params":{}}

I[23:04:09.407] <-- initialized
I[23:04:09.407] unhandled notification initialized
V[23:04:09.408] <<< {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"objective-cpp","text":"#import <Foundation/Foundation.h>\n\n#include <memory>\n#include <vector>\n\nNS_ASSUME_NONNULL_BEGIN\n\n@interface MyBuffer : NSObject\n@end\n\n@interface MyBuffer () {\n  std::unique_ptr<std::vector<char>> data_;\n}\n@end\n\nNS_ASSUME_NONNULL_END\n\n@implementation MyBuffer\n\n- (instancetype)initWithSize:(size_t)size {\n  if (self = [super init]) {\n    data_.reset(new std::vector<char>(size));\n  }\n  return self;\n}\n\n@end\n","uri":"file:///private/tmp/test/test.mm","version":1}}}

I[23:04:09.408] <-- textDocument/didOpen
I[23:04:09.411] Enqueueing 1 commands for indexing
I[23:04:09.412] --> textDocument/clangd.fileStatus
V[23:04:09.412] Failed to load shard: /private/tmp/test/test.mm
V[23:04:09.412] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes","uri":"file:///private/tmp/test/test.mm"}}

I[23:04:09.412] Updating file /private/tmp/test/test.mm with command
[/private/tmp/test]
/Applications/Xcode11.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -std=c++14 -isysroot /Applications/Xcode11.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -mmacosx-version-min=10.10.0 -c test.mm -o test.o -fsyntax-only -resource-dir=/Users/leebc/.local/llvm/lib/clang/10.0.0
V[23:04:09.414] Indexing test.mm (digest:=95A17ABEE863AAE7)
V[23:04:09.419] Driver produced command: cc1 -cc1 -triple x86_64-apple-macosx10.10.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -fsyntax-only -disable-free -main-file-name test.mm -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=all -fno-rounding-math -masm-verbose -munwind-tables -faligned-alloc-unavailable -target-sdk-version=10.15.4 -target-cpu core2 -dwarf-column-info -debugger-tuning=lldb -target-linker-version 556.6 -resource-dir /Users/leebc/.local/llvm/lib/clang/10.0.0 -isysroot /Applications/Xcode11.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -stdlib=libc++ -internal-isystem /Applications/Xcode11.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1 -internal-isystem /Applications/Xcode11.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/c++/v1 -internal-isystem /Applications/Xcode11.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/local/include -internal-isystem /Users/leebc/.local/llvm/lib/clang/10.0.0/include -internal-externc-isystem /Applications/Xcode11.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include -std=c++14 -fdeprecated-macro -fdebug-compilation-dir /private/tmp/test -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fobjc-runtime=macosx-10.10.0 -fobjc-exceptions -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -x objective-c++ test.mm
V[23:04:09.419] Building first preamble for /private/tmp/test/test.mm
V[23:04:09.469] <<< {"id":1,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///private/tmp/test/test.mm"}}}

I[23:04:09.469] <-- textDocument/documentSymbol(1)
V[23:04:09.470] <<< {"id":2,"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"context":{"diagnostics":[]},"range":{"end":{"character":23,"line":5},"start":{"character":23,"line":5}},"textDocument":{"uri":"file:///private/tmp/test/test.mm"}}}

I[23:04:09.470] <-- textDocument/codeAction(2)
V[23:04:09.472] <<< {"id":3,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///private/tmp/test/test.mm"}}}

I[23:04:09.472] <-- textDocument/documentLink(3)
V[23:04:09.570] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":1}}

I[23:04:09.570] <-- $/cancelRequest
V[23:04:09.570] <<< {"id":4,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///private/tmp/test/test.mm"}}}

I[23:04:09.570] <-- textDocument/documentSymbol(4)
V[23:04:10.599] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":2}}

I[23:04:10.599] <-- $/cancelRequest
V[23:04:10.599] <<< {"id":5,"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"context":{"diagnostics":[]},"range":{"end":{"character":23,"line":5},"start":{"character":23,"line":5}},"textDocument":{"uri":"file:///private/tmp/test/test.mm"}}}

I[23:04:10.599] <-- textDocument/codeAction(5)
V[23:04:14.783] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":5}}

I[23:04:14.783] <-- $/cancelRequest
V[23:04:16.773] <<< {"id":6,"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"context":{"diagnostics":[]},"range":{"end":{"character":14,"line":23},"start":{"character":14,"line":23}},"textDocument":{"uri":"file:///private/tmp/test/test.mm"}}}

I[23:04:16.773] <-- textDocument/codeAction(6)
V[23:04:29.117] <<< {"id":7,"jsonrpc":"2.0","method":"textDocument/documentHighlight","params":{"position":{"character":4,"line":26},"textDocument":{"uri":"file:///private/tmp/test/test.mm"}}}

I[23:04:29.117] <-- textDocument/documentHighlight(7)
V[23:04:29.368] <<< {"id":8,"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"context":{"diagnostics":[]},"range":{"end":{"character":4,"line":26},"start":{"character":4,"line":26}},"textDocument":{"uri":"file:///private/tmp/test/test.mm"}}}

I[23:04:29.368] <-- textDocument/codeAction(8)
V[23:04:29.368] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":6}}

I[23:04:29.368] <-- $/cancelRequest
V[23:04:30.208] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":7}}

I[23:04:30.208] <-- $/cancelRequest
V[23:04:30.209] <<< {"id":9,"jsonrpc":"2.0","method":"textDocument/documentHighlight","params":{"position":{"character":25,"line":0},"textDocument":{"uri":"file:///private/tmp/test/test.mm"}}}

I[23:04:30.209] <-- textDocument/documentHighlight(9)
V[23:04:30.452] <<< {"id":10,"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"context":{"diagnostics":[]},"range":{"end":{"character":25,"line":0},"start":{"character":25,"line":0}},"textDocument":{"uri":"file:///private/tmp/test/test.mm"}}}

I[23:04:30.452] <-- textDocument/codeAction(10)
V[23:04:30.453] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":8}}

I[23:04:30.453] <-- $/cancelRequest
V[23:04:30.669] <<< {"id":11,"jsonrpc":"2.0","method":"textDocument/hover","params":{"position":{"character":25,"line":0},"textDocument":{"uri":"file:///private/tmp/test/test.mm"}}}

I[23:04:30.669] <-- textDocument/hover(11)
V[23:04:31.511] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":11}}

I[23:04:31.511] <-- $/cancelRequest
V[23:04:31.512] <<< {"id":12,"jsonrpc":"2.0","method":"textDocument/definition","params":{"position":{"character":25,"line":0},"textDocument":{"uri":"file:///private/tmp/test/test.mm"}}}

I[23:04:31.512] <-- textDocument/definition(12)
V[23:04:37.225] index AST for test.mm (main=false):
  symbol slab: 58074 symbols, 19842828 bytes
  ref slab: 0 symbols, 0 refs, 136 bytes
  relations slab: 420 relations, 8728 bytes
V[23:04:47.916] Built preamble of size 21294484 for file /private/tmp/test/test.mm
Assertion failed: (!StringRef(QName).startswith("::")), function printQualifiedName, file /Users/leebc/src/llvm-project/clang-tools-extra/clangd/AST.cpp, line 180.
0  clangd                   0x000000010a1e2c6a llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 58
1  clangd                   0x000000010a1e31d9 PrintStackTraceSignalHandler(void*) + 25
2  clangd                   0x000000010a1e0fab llvm::sys::RunSignalHandlers() + 123
3  clangd                   0x000000010a1e63b9 SignalHandler(int) + 249
4  libsystem_platform.dylib 0x00007fff6ba385fd _sigtramp + 29
5  clangd                   0x000000010fa4f9d1 llvm::remarks::YAMLParseError::ID + 2563860
6  libsystem_c.dylib        0x00007fff6b90e808 abort + 120
7  libsystem_c.dylib        0x00007fff6b90dac6 err + 0
8  clangd                   0x000000010c2ab8b2 clang::clangd::printQualifiedName(clang::NamedDecl const&) + 226
9  clangd                   0x000000010c8d739d clang::clangd::SymbolCollector::addDeclaration(clang::NamedDecl const&, clang::clangd::SymbolID, bool) + 157
10 clangd                   0x000000010c8d6d44 clang::clangd::SymbolCollector::handleDeclOccurrence(clang::Decl const*, unsigned int, llvm::ArrayRef<clang::index::SymbolRelation>, clang::SourceLocation, clang::index::IndexDataConsumer::ASTNodeInfo) + 2180
11 clangd                   0x000000010e5d4c5c clang::index::IndexingContext::handleDeclOccurrence(clang::Decl const*, clang::SourceLocation, bool, clang::Decl const*, unsigned int, llvm::ArrayRef<clang::index::SymbolRelation>, clang::Expr const*, clang::Decl const*, clang::DeclContext const*) + 1580
12 clangd                   0x000000010e5d4616 clang::index::IndexingContext::handleDecl(clang::Decl const*, clang::SourceLocation, unsigned int, llvm::ArrayRef<clang::index::SymbolRelation>, clang::DeclContext const*) + 262
13 clangd                   0x000000010e5d44f7 clang::index::IndexingContext::handleDecl(clang::Decl const*, unsigned int, llvm::ArrayRef<clang::index::SymbolRelation>) + 119
14 clangd                   0x000000010e5c881b (anonymous namespace)::IndexingDeclVisitor::VisitObjCIvarDecl(clang::ObjCIvarDecl const*) + 155
15 clangd                   0x000000010e5c5bc6 clang::declvisitor::Base<llvm::make_const_ptr, (anonymous namespace)::IndexingDeclVisitor, bool>::Visit(clang::Decl const*) + 1510
16 clangd                   0x000000010e5c553e clang::index::IndexingContext::indexDecl(clang::Decl const*) + 158
17 clangd                   0x000000010e5c6115 clang::index::IndexingContext::indexDeclContext(clang::DeclContext const*) + 149
18 clangd                   0x000000010e5c6bc4 (anonymous namespace)::IndexingDeclVisitor::VisitObjCCategoryDecl(clang::ObjCCategoryDecl const*) + 772
19 clangd                   0x000000010e5c5826 clang::declvisitor::Base<llvm::make_const_ptr, (anonymous namespace)::IndexingDeclVisitor, bool>::Visit(clang::Decl const*) + 582
20 clangd                   0x000000010e5c553e clang::index::IndexingContext::indexDecl(clang::Decl const*) + 158
21 clangd                   0x000000010e5c61c2 clang::index::IndexingContext::indexTopLevelDecl(clang::Decl const*) + 114
22 clangd                   0x000000010e5cdc38 clang::index::indexTopLevelDecls(clang::ASTContext&, clang::Preprocessor&, llvm::ArrayRef<clang::Decl const*>, clang::index::IndexDataConsumer&, clang::index::IndexingOptions) + 232
23 clangd                   0x000000010c85a65f clang::clangd::indexSymbols(clang::ASTContext&, std::__1::shared_ptr<clang::Preprocessor>, llvm::ArrayRef<clang::Decl*>, clang::clangd::MainFileMacros const*, clang::clangd::CanonicalIncludes const&, bool) + 495
24 clangd                   0x000000010c85a454 clang::clangd::indexMainDecls(clang::clangd::ParsedAST&) + 132
25 clangd                   0x000000010c85eb16 clang::clangd::FileIndex::updateMain(llvm::StringRef, clang::clangd::ParsedAST&) + 54
26 clangd                   0x000000010c3f0f75 clang::clangd::(anonymous namespace)::UpdateIndexCallbacks::onMainAST(llvm::StringRef, clang::clangd::ParsedAST&, llvm::function_ref<void (llvm::function_ref<void ()>)>) + 101
27 clangd                   0x000000010c78384b clang::clangd::(anonymous namespace)::ASTWorker::update(clang::clangd::ParseInputs, clang::clangd::WantDiagnostics)::$_0::operator()() + 3467
28 clangd                   0x000000010c782a58 void llvm::unique_function<void ()>::CallImpl<clang::clangd::(anonymous namespace)::ASTWorker::update(clang::clangd::ParseInputs, clang::clangd::WantDiagnostics)::$_0>(void*) + 24
29 clangd                   0x0000000109ff0012 llvm::unique_function<void ()>::operator()() + 146
30 clangd                   0x000000010c77a39f clang::clangd::(anonymous namespace)::ASTWorker::run() + 1583
31 clangd                   0x000000010c779d3d clang::clangd::(anonymous namespace)::ASTWorker::create(llvm::StringRef, clang::clangd::GlobalCompilationDatabase const&, clang::clangd::TUScheduler::ASTCache&, clang::clangd::AsyncTaskRunner*, clang::clangd::Semaphore&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >, bool, clang::clangd::ParsingCallbacks&)::$_5::operator()() const + 29
32 clangd                   0x000000010c779c58 void llvm::unique_function<void ()>::CallImpl<clang::clangd::(anonymous namespace)::ASTWorker::create(llvm::StringRef, clang::clangd::GlobalCompilationDatabase const&, clang::clangd::TUScheduler::ASTCache&, clang::clangd::AsyncTaskRunner*, clang::clangd::Semaphore&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >, bool, clang::clangd::ParsingCallbacks&)::$_5>(void*) + 24
33 clangd                   0x0000000109ff0012 llvm::unique_function<void ()>::operator()() + 146
34 clangd                   0x000000010c76649f clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_4::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, llvm::unique_function<void ()>, llvm::detail::scope_exit<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_0>) const + 47
35 clangd                   0x000000010c766379 decltype(std::__1::forward<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_4>(fp)(std::__1::forward<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(fp0), std::__1::forward<llvm::unique_function<void ()> >(fp0), std::__1::forward<llvm::detail::scope_exit<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_0> >(fp0))) std::__1::__invoke<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_4, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, llvm::unique_function<void ()>, llvm::detail::scope_exit<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_0> >(clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_4&&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, llvm::unique_function<void ()>&&, llvm::detail::scope_exit<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_0>&&) + 121
36 clangd                   0x000000010c766280 void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_4, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, llvm::unique_function<void ()>, llvm::detail::scope_exit<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_0>, 2ul, 3ul, 4ul>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_4, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, llvm::unique_function<void ()>, llvm::detail::scope_exit<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_0> >&, std::__1::__tuple_indices<2ul, 3ul, 4ul>) + 112
37 clangd     [Info  - 11:04:48 PM] Connection to server got closed. Server will restart.
[Error - 11:04:48 PM] Request textDocument/documentSymbol failed.
Error: Connection got disposed.
	at Object.dispose (/Users/leebc/.vscode/extensions/llvm-vs-code-extensions.vscode-clangd-0.1.1/node_modules/vscode-jsonrpc/lib/main.js:904:25)
	at Object.dispose (/Users/leebc/.vscode/extensions/llvm-vs-code-extensions.vscode-clangd-0.1.1/node_modules/vscode-languageclient/lib/client.js:74:35)
	at ClangdLanguageClient.handleConnectionClosed (/Users/leebc/.vscode/extensions/llvm-vs-code-extensions.vscode-clangd-0.1.1/node_modules/vscode-languageclient/lib/client.js:2309:42)
	at ClangdLanguageClient.handleConnectionClosed (/Users/leebc/.vscode/extensions/llvm-vs-code-extensions.vscode-clangd-0.1.1/node_modules/vscode-languageclient/lib/main.js:155:15)
	at closeHandler (/Users/leebc/.vscode/extensions/llvm-vs-code-extensions.vscode-clangd-0.1.1/node_modules/vscode-languageclient/lib/client.js:2296:18)
	at CallbackList.invoke (/Users/leebc/.vscode/extensions/llvm-vs-code-extensions.vscode-clangd-0.1.1/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/Users/leebc/.vscode/extensions/llvm-vs-code-extensions.vscode-clangd-0.1.1/node_modules/vscode-jsonrpc/lib/events.js:121:36)
	at closeHandler (/Users/leebc/.vscode/extensions/llvm-vs-code-extensions.vscode-clangd-0.1.1/node_modules/vscode-jsonrpc/lib/main.js:240:26)
	at CallbackList.invoke (/Users/leebc/.vscode/extensions/llvm-vs-code-extensions.vscode-clangd-0.1.1/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/Users/leebc/.vscode/extensions/llvm-vs-code-extensions.vscode-clangd-0.1.1/node_modules/vscode-jsonrpc/lib/events.js:121:36)
	at StreamMessageWriter.fireClose (/Users/leebc/.vscode/extensions/llvm-vs-code-extensions.vscode-clangd-0.1.1/node_modules/vscode-jsonrpc/lib/messageWriter.js:39:27)
	at Socket.<anonymous> (/Users/leebc/.vscode/extensions/llvm-vs-code-extensions.vscode-clangd-0.1.1/node_modules/vscode-jsonrpc/lib/messageWriter.js:58:46)
	at Socket.emit (events.js:203:13)
	at Pipe.<anonymous> (net.js:588:12)

@hokein
Copy link
Contributor

hokein commented May 7, 2020

Thanks for the details, I can reproduce the crash at HEAD, https://reviews.llvm.org/D79576 is a fix.

From my tests using clangd plugin of VS Code, 1 and 2 (My builds) have triggered an assertion whereas 3 does not trigger any issue. It is weird.

yeah, I think the clangd 10 binary from homebrew is not built with assertion enabled, so it won't trigger the crash.

hokein added a commit to llvm/llvm-project that referenced this issue May 19, 2020
…extension.

Summary:
Similar to property, we print the containing interface decl as the
nested name specifier for ivar; otherwise we will get "::ivar_name".

this would fix an assertion crash in clangd: clangd/clangd#365

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79576
@hokein hokein closed this as completed May 19, 2020
hanswinderix pushed a commit to hanswinderix/llvm-project that referenced this issue May 27, 2020
…extension.

Summary:
Similar to property, we print the containing interface decl as the
nested name specifier for ivar; otherwise we will get "::ivar_name".

this would fix an assertion crash in clangd: clangd/clangd#365

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79576
arichardson pushed a commit to arichardson/llvm-project that referenced this issue Jul 2, 2020
…extension.

Summary:
Similar to property, we print the containing interface decl as the
nested name specifier for ivar; otherwise we will get "::ivar_name".

this would fix an assertion crash in clangd: clangd/clangd#365

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79576
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
…extension.

Summary:
Similar to property, we print the containing interface decl as the
nested name specifier for ivar; otherwise we will get "::ivar_name".

this would fix an assertion crash in clangd: clangd/clangd#365

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79576
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants