microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.5k stars 1.55k forks source link

IntelliSense crash parsing file #11900

Open dlenihan-latai opened 8 months ago

dlenihan-latai commented 8 months ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary: IntelliSense crashes when parsing a file.

Steps to reproduce:

  1. Create an empty file and add this content

    
    template <typename T>
    struct S
    {
    // To see IntelliSense crash, look in VSCode > Terminal > Output > C/C++
    // You will see this message:
    //    IntelliSense process crash detected: handle_update_intellisense
    
    // Comment out next line to avoid IntelliSense crash.
    static constexpr auto lambda = [](auto) noexcept(true) {};
    };

S s;

2. Save file as `intellisense_crash.cc`
3. Look at `VSCode > Terminal > Output > C/C++` and see error message "IntelliSense process crash detected: handle_update_intellisense"

Expected behavior: IntelliSense does not crash for a file clang can compile.

_NOTE: I realize this sample code does nothing. I took actual code that was crashing and minimized it to focus on just the code related to the IntelliSense crash so that I could give an easy repro and avoid issues with sharing company code. FYI: The clangd plugin does NOT crash in this code._

### Configuration and Logs

```shell
NOTE: Removed anything related to our source code -> <SNIP>
=======================================================
c_cpp_properties.json
{
    "configurations": [
        {
            "name": "Linux",
            "compilerPath": "<SNIP>/llvm11/usr/bin/clang",
            "compilerArgs": [
                "<SNIP>"        
            ],
            "defines": [
                "<SNIP>"
            ],
            "includePath": [
                "<SNIP>"
            ],
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-clang-x64"
        }
    ],
    "version": 4
}

=======================================================
C/C++: Log Diagnostics
-------- Diagnostics - 1/26/2024, 3:01:38 PM
Version: 1.18.5
Current Configuration:
{
    "name": "Linux",
    "compilerPath": "<SNIP>/llvm11/usr/bin/clang",
    "compilerArgs": [
        "<SNIP>"
    ],
    "defines": [
        "<SNIP>"
    ],
    "includePath": [
        "<SNIP>"
    ],
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "linux-clang-x64",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "compilerPathInCppPropertiesJson": "<SNIP>/llvm11/usr/bin/clang",
    "mergeConfigurations": false,
    "browse": {
        "path": [
            "<SNIP>"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
cpptools version (native): 1.18.3.0
Translation Unit Mappings:
[ <SNIP>/intellisense_crash.cc ]:
    <SNIP>/intellisense_crash.cc
Translation Unit Configurations:
[ <SNIP>/intellisense_crash.cc ]: not ready
    Process ID: 1347195
    Memory Usage: 0 MB
    Compiler Path: <SNIP>/llvm11/usr/bin/clang
    Includes:
        <SNIP>
    Defines:
        <SNIP>
    Standard Version: c++17
    IntelliSense Mode: linux-clang-x64
    Other Flags:
        --clang
        --clang_version=110100
Total Memory Usage: 0 MB
=======================================================
Language Server Logging
loggingLevel: Debug
LSP: (received) cpptools/initialize (id: 1)
LSP: (invoked) cpptools/initialize (id: 1)
cpptools version (TypeScript): 1.18.5
cpptools version (native): 1.18.3.0
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Hover is enabled.
IntelliSense Engine = default.
LSP: (received) cpptools/queryCompilerDefaults (id: 2)
LSP: (invoked) cpptools/queryCompilerDefaults (id: 2)
LSP: (received) cpptools/didChangeCppProperties (id: 3)
LSP: (received) cpptools/queryCompilerDefaults (id: 4)
Querying compiler for default C++ language standard using command line: '<SNIP>/llvm11/usr/bin/clang' -x c++ -E -dM /dev/null
Querying compiler for default C language standard using command line: '<SNIP>/llvm11/usr/bin/clang' -x c -E -dM /dev/null
Querying compiler for default C++ language standard using command line: /usr/bin/clang -x c++ -E -dM /dev/null
Detected language standard version: c++17
Querying compiler's default target using command line: "/usr/bin/clang" -dumpmachine
Compiler returned default target value: x86_64-pc-linux-gnu
Compiler query command line: /usr/bin/clang -std=c17 -m64 -Wp,-v -fno-blocks -E -dM -x c /dev/null
Attempting to get defaults from C compiler in "compilerPath" property: '/usr/bin/clang'
Compiler query command line: /usr/bin/clang -std=c++17 -m64 -Wp,-v -fno-blocks -E -dM -x c++ /dev/null
Attempting to get defaults from C++ compiler in "compilerPath" property: '/usr/bin/clang'
LSP: (invoked) cpptools/didChangeCppProperties (id: 3)
Code browsing service initialized
Querying compiler for default C++ language standard using command line: <SNIP>/llvm11/usr/bin/clang -x c++ -E -dM /dev/null
Detected language standard version: c++14
Querying compiler's default target using command line: "<SNIP>/llvm11/usr/bin/clang" -dumpmachine
Compiler returned default target value: x86_64-unknown-linux-gnu
Compiler query command line: <SNIP>/llvm11/usr/bin/clang -pipe -g0 -O3 -std=gnu++1z -no-canonical-prefixes -nostdinc -nostdinc++ -fcolor-diagnostics -fdata-sections -ffp-contract=fast -ffunction-sections -fno-omit-frame-pointer -fno-strict-aliasing -fPIC -march=haswell -Wall -Wextra -Wno-builtin-macro-redefined -Wno-defaulted-function-deleted -Wno-delete-non-abstract-non-virtual-dtor -Wno-error=deprecated-declarations -Wno-implicit-int-float-conversion -Wno-inconsistent-missing-override -Wno-gnu-string-literal-operator-template -Wno-missing-braces -Wno-missing-field-initializers -Wno-sign-compare -Wno-sign-conversion -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-result -Wno-non-virtual-dtor -Wno-writable-strings -Wself-assign -Wthread-safety -Wunreachable-code -Wunused-function -m64 -Wp,-v -fno-blocks -E -dM -x c++ /dev/null
Attempting to get defaults from C++ compiler in "compilerPath" property: '<SNIP>/llvm11/usr/bin/clang'
Compiler query command line: <SNIP>/llvm11/usr/bin/clang -pipe -g0 -O3 -no-canonical-prefixes -nostdinc -nostdinc++ -fcolor-diagnostics -fdata-sections -ffp-contract=fast -ffunction-sections -fno-omit-frame-pointer -fno-strict-aliasing -fPIC -march=haswell -Wall -Wextra -Wno-builtin-macro-redefined -Wno-defaulted-function-deleted -Wno-delete-non-abstract-non-virtual-dtor -Wno-error=deprecated-declarations -Wno-implicit-int-float-conversion -Wno-inconsistent-missing-override -Wno-gnu-string-literal-operator-template -Wno-missing-braces -Wno-missing-field-initializers -Wno-sign-compare -Wno-sign-conversion -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-result -Wno-non-virtual-dtor -Wno-writable-strings -Wself-assign -Wthread-safety -Wunreachable-code -Wunused-function -std=c17 -m64 -Wp,-v -fno-blocks -E -dM -x c /dev/null
Attempting to get defaults from C compiler in "compilerPath" property: '<SNIP>/llvm11/usr/bin/clang'
  <SNIP>
LSP: (invoked) cpptools/queryCompilerDefaults (id: 4)
Querying compiler for default C++ language standard using command line: '<SNIP>/llvm11/usr/bin/clang' -x c++ -E -dM /dev/null
Discovering files...
Querying compiler for default C language standard using command line: '<SNIP>/llvm11/usr/bin/clang' -x c -E -dM /dev/null
  <SNIP>
LSP: (received) cpptools/didChangeCppProperties (id: 5)
LSP: (invoked) cpptools/didChangeCppProperties (id: 5)
LSP: (received) textDocument/didOpen: file:///<SNIP>/intellisense_crash.cc
LSP: (invoked) textDocument/didOpen: file:///<SNIP>/intellisense_crash.cc
  tag parsing file: <SNIP>/intellisense_crash.cc
sending compilation args for <SNIP>/intellisense_crash.cc
  include: <SNIP>
  define: <SNIP>
  other: --clang
  other: --clang_version=110100
  stdver: c++17
  intelliSenseMode: linux-clang-x64
LSP: (received) cpptools/getInlayHints: file:///<SNIP>/intellisense_crash.cc (id: 6)
LSP: (invoked) cpptools/getInlayHints: file:///<SNIP>/intellisense_crash.cc (id: 6)
LSP: (received) cpptools/getDocumentSymbols: file:///<SNIP>/intellisense_crash.cc (id: 7)
LSP: (invoked) cpptools/getDocumentSymbols: file:///<SNIP>/intellisense_crash.cc (id: 7)
LSP: (received) cpptools/getFoldingRanges: file:///<SNIP>/intellisense_crash.cc (id: 8)
LSP: (invoked) cpptools/getFoldingRanges: file:///<SNIP>/intellisense_crash.cc (id: 8)
LSP: (received) cpptools/activeDocumentChange: file:///<SNIP>/intellisense_crash.cc
LSP: (invoked) cpptools/activeDocumentChange: file:///<SNIP>/intellisense_crash.cc
LSP: (received) cpptools/textEditorSelectionChange
LSP: $/cancelRequest (cpptools/getDocumentSymbols, id: 7)
LSP: $/cancelRequest (<unknown/completed>, id: 8)
LSP: (invoked) cpptools/textEditorSelectionChange
Checking for syntax errors: /<SNIP>/intellisense_crash.cc
Queueing IntelliSense update for files in translation unit of: /<SNIP>/intellisense_crash.cc
LSP: (received) cpptools/getDocumentSymbols: file:///<SNIP>/intellisense_crash.cc (id: 9)
LSP: (invoked) cpptools/getDocumentSymbols: file:///<SNIP>/intellisense_crash.cc (id: 9)
LSP: (received) cpptools/getSemanticTokens: file:///<SNIP>/intellisense_crash.cc (id: 10)
LSP: (invoked) cpptools/getSemanticTokens: file:///<SNIP>/intellisense_crash.cc (id: 10)
LSP: (received) cpptools/getDocumentSymbols: file:///<SNIP>/intellisense_crash.cc (id: 11)
LSP: (invoked) cpptools/getDocumentSymbols: file:///<SNIP>/intellisense_crash.cc (id: 11)
LSP: (received) cpptools/getFoldingRanges: file:///<SNIP>/intellisense_crash.cc (id: 12)
LSP: (invoked) cpptools/getFoldingRanges: file:///<SNIP>/intellisense_crash.cc (id: 12)
IntelliSense process crash detected: handle_update_intellisense
Checking for syntax errors: /<SNIP>/intellisense_crash.cc
Update IntelliSense time (sec): 0.352
LSP: $/cancelRequest (cpptools/getInlayHints, id: 6)
LSP: (received) cpptools/getInlayHints: file:///<SNIP>/intellisense_crash.cc (id: 13)
LSP: (invoked) cpptools/getInlayHints: file:///<SNIP>/intellisense_crash.cc (id: 13)
LSP: Request canceled by server (<unknown/completed>, code: -32802, id: 6)
LSP: (received) cpptools/pauseCodeAnalysis
LSP: (invoked) cpptools/pauseCodeAnalysis
LSP: (received) cpptools/resumeCodeAnalysis
LSP: (invoked) cpptools/resumeCodeAnalysis
LSP: (received) cpptools/pauseCodeAnalysis
LSP: (invoked) cpptools/pauseCodeAnalysis

Other Extensions

N/A

Additional context

No response

sean-mcmanus commented 6 months ago

@dlenihan-latai I've filed a bug on VS for our shared parser at https://developercommunity.visualstudio.com/t/IntelliSense-engine-crashed-in-add_cache/10619523 .