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 fallback logic can miss changes when using multiple configurations with different compile_commands.json paths #12947

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

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:
Assuming file watchers have failed/closed, the fallback logic CppProperties.checkCompileCommands can fail to detect changes in a compile_commands.json from a different configuration index (even when later switching to that configuration index)

Steps to reproduce:
Assume the following c_cpp_properties.json (only relevant parts shown)

{
    "configurations": [
        {
            "name": "compdb1",
            "compileCommands": "${workspaceFolder}/compile_commands_1.json",
        },
        {
            "name": "compdb2",
            "compileCommands": "${workspaceFolder}/compile_commands_2.json",
        }
    ],
    "version": 4
}
  1. Assume we are using compdb1
  2. Assume file watchers failed/closed on any of the example reasons:
  3. Update compile_commands_2.json (by touching or actually compiling some CMake project)
    • Assuming file watchers are closed/failed, no event is triggered on this change.
    • checkCompileCommands() only checks the file used by the current configuration, no event is triggered on this change.
  4. Update compile_commands_1.json
    • Now, compile_commands_1.json is newer than compile_commands_2.json.
    • CppProperties.compileCommandsFileWatcherFallbackTime is assigned compile_commands_1.json's timestamp.
  5. Switch to compdb2
    • File watchers are re-created, but no event is triggered as compile_commands_2.json has changed before re-initializing the file watchers.
    • CppProperties.compileCommandsFileWatcherFallbackTime is a newer timestamp than compile_commands_2.json's timestamp, so checkCompileCommands() does not trigger an event.

Configuration and Logs

{
    "configurations": [
        {
            "name": "compdb1",
            "compileCommands": "${workspaceFolder}/compile_commands_1.json",
        },
        {
            "name": "compdb2",
            "compileCommands": "${workspaceFolder}/compile_commands_2.json",
        }
    ],
    "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.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants