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

Compile commands file watchers are leaked without being closed #12946

Closed
yiftahw opened this issue Nov 9, 2024 · 0 comments · Fixed by #12948
Closed

Compile commands file watchers are leaked without being closed #12946

yiftahw opened this issue Nov 9, 2024 · 0 comments · Fixed by #12948
Assignees
Labels
bug Feature: Compile Commands help wanted Can be fixed in the public (open source) repo. Language Service
Milestone

Comments

@yiftahw
Copy link
Contributor

yiftahw commented Nov 9, 2024

Environment

  • OS and Version: Windows 10
  • VS Code Version: 1.95.1
  • C/C++ Extension Version: V1.22.11
  • If using SSH remote, specify OS of remote machine:

Bug Summary and Steps to Reproduce

Bug Summary:

When using compileCommands in a configuration, deleting the json file causes the fallback function checkCompileCommands() in src\LanguageServer\configurations.ts to dispose the file watchers without closing them.

Steps to reproduce:

  1. Use the compileCommands configuration with a path to a compile_commands.json.
  2. Update the file's timestamp. (touch it or compile a CMake project which updates it)
    • CppProperties.compileCommandsFile is updated with a value.
  3. Delete or rename the file.
  4. next periodic call to checkCompileCommands() will enter the error case and leak the file watchers.
// in checkCompileCommands()
fs.stat(compileCommandsFile, (err, stats) => {
    if (err) {
        if (err.code === "ENOENT" && this.compileCommandsFile) {
            // file watchers should be closed here
            this.compileCommandsFileWatchers = []; // reset file watchers

Expected behavior:
checkCompileCommands() should close the file watchers before disposing.

Configuration and Logs

{
    "configurations": [
        {
            "name": "compdb1",
            "compileCommands": "${workspaceFolder}/compile_commands_1.json",
            "intelliSenseMode": "windows-msvc-x64",
            "cStandard": "c17",
            "cppStandard": "c++17"
        },
        {
            "name": "compdb2",
            "compileCommands": "${workspaceFolder}/compile_commands_2.json",
            "intelliSenseMode": "linux-gcc-x64",
            "cStandard": "c17",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}

Other Extensions

No response

Additional context

No response

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Feature: Compile Commands help wanted Can be fixed in the public (open source) repo. Language Service
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants