vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Use of `/` as an include path causes crash/freeze on macOS

Open sangraamp opened this issue 1 year ago • 3 comments
trafficstars

Environment

  • OS and Version: macOS Sonoma 14.3.1 (23D60)
  • VS Code Version: 1.86.2
  • C/C++ Extension Version: v1.18.5
  • If using SSH remote, specify OS of remote machine: N/A

Bug Summary and Steps to Reproduce

Bug Summary:

Pre-release version: Screenshot 2024-02-21 at 3 44 59 PM

Release version: Screenshot 2024-02-21 at 3 52 27 PM

Steps to reproduce: Not aware of this as of now.

Expected behavior: N/A

Configuration and Logs

Configurations in c_cpp_properties.json:
{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**",
                "/"
            ],
            "defines": [],
            "macFrameworkPath": [
                "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
            ],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "macos-clang-x64",
            "configurationProvider": "ms-vscode.makefile-tools"
        }
    ],
    "version": 4
}

Logs from running C/C++: Log Diagnostics from the VS Code command palette:
N/A (not able to get the logs)

Logs from the 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: /usr/bin/clang -x c++ -E -dM /dev/null
Compiler returned default language standard version: c++98. Since this version is old, will try to use newer version c++17 as default.
Querying compiler's default target using command line: "/usr/bin/clang" -dumpmachine
Compiler returned default target value: x86_64-apple-darwin23.3.0
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
  /Users/apple/2D Physics Engine/** is not a directory
Custom configuration provider 'Makefile Tools' registered
LSP: (received - deferred) cpptools/fileCreated: file:///Users/apple/2D%20Physics%20Engine/.git/.gitstatus.5vKTiE
LSP: (received - deferred) cpptools/fileCreated: file:///Users/apple/2D%20Physics%20Engine/.git/.gitstatus.5vKTiE/a
LSP: (received - deferred) cpptools/fileCreated: file:///Users/apple/2D%20Physics%20Engine/.git/.gitstatus.5vKTiE/b
LSP: (received - deferred) cpptools/fileDeleted: file:///Users/apple/2D%20Physics%20Engine/.git/.gitstatus.5vKTiE
LSP: (received - deferred) cpptools/fileCreated: file:///Users/apple/2D%20Physics%20Engine/.git/index
LSP: (received - deferred) cpptools/fileDeleted: file:///Users/apple/2D%20Physics%20Engine/.git/index.lock
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/didChangeCppProperties (id: 2)
LSP: (invoked) cpptools/didChangeCppProperties (id: 2)
LSP: (received) cpptools/queryCompilerDefaults (id: 3)
Warning: Database safety check failed. Recreating database.
[rc=0x80004005] (DB: false, Expected: true)
Code browsing service initialized
Querying compiler for default C++ language standard using command line: /usr/bin/clang -x c++ -E -dM /dev/null
Compiler returned default language standard version: c++98. Since this version is old, will try to use newer version c++17 as default.
Querying compiler's default target using command line: "/usr/bin/clang" -dumpmachine
Compiler returned default target value: x86_64-apple-darwin23.3.0
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'
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'
  /Users/apple/2D Physics Engine/** is not a directory

I don't know why it says the folder isn't a directory, I can access it via the terminal.

Other Extensions

No response

Additional context

Here are the folder permissions: drwxr-xr-x@ 15 apple staff 480 Feb 21 12:11 2D Physics Engine

sangraamp avatar Feb 21 '24 10:02 sangraamp

Hi @sangraamp . Since we're not tracking an issue blocking all Mac users, there may be something about your system or configuration that we may need to uncover to understand what's happening.

Does this happen for you with a simple project, such as a folder containing just a single, simple source file?

I noticed that you've specified "/" as an include path. Since it's unlikely that you have header files located directly at the root of your file system, I don't think this is needed. I suspect this is resulting in the C/C++ extension trying to ingest your entire file system into its browse database, possibly crashing due to running out of memory. Does the issue still occur if you remove that?

Colengms avatar Feb 21 '24 23:02 Colengms

Well, thanks for that, @Colengms! Looks like that was the issue, it is working now.

sangraamp avatar Feb 22 '24 08:02 sangraamp

@sangraamp Fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.20.3

sean-mcmanus avatar May 01 '24 00:05 sean-mcmanus