microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.46k stars 451 forks source link

Reconnecting after stopping/canceling build #4128

Open i-ky opened 2 days ago

i-ky commented 2 days ago

Brief Issue Summary

I am working on a project using CMake Tools and Dev Containers. There is a target that executes run-clang-tidy analysis:

add_custom_target(clang-tidy
    COMMAND run-clang-tidy -fix
    COMMENT "Running clang-tidy..."
    VERBATIM
    USES_TERMINAL
)

This target is quite "heavy" and long-running, so sometimes it needs to be stopped/canceled to free up CPU and memory for other more pressing tasks.

At first build seems to be stopping normally, I see processes terminating in the Output, CPU utilization drops as expected, but then VS Code throws:

Attempting to reconnect in N seconds...

...and enters a seemingly infinite loop attempting to reconnect.

The only thing that helps is clicking Reload Window button, but this leads to the loss of some part of IDE state (terminal window contents, etc.)

CMake Tools Diagnostics

{
  "os": "linux",
  "vscodeVersion": "1.94.1",
  "cmtVersion": "1.19.52",
  "configurations": [
    {
      "folder": "/home/dev_user/some_project",
      "cmakeVersion": "3.29.7",
      "configured": true,
      "generator": "Ninja",
      "usesPresets": true,
      "compilers": {
        "CXX": "/usr/bin/c++"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": false,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    }
  ]
}

Debug Log

[main] Building folder: /home/dev_user/some_project/build 
[main] Saving open files before configure/build
[build] Starting build
[driver] Start build clang-tidy
[proc] Executing command: /usr/bin/cmake --build /home/dev_user/some_project/build --target clang-tidy --
[proc]   with environment: {"DB_OPTIONS":"?sslmode=disable","REDIS_PORT":"6379","DATABASE_URL":"postgres://user:password@postgres:5432/database?sslmode=disable","HOSTNAME":"55c7c5ccb482","DB_PORT":"5432","HOME":"/home/dev_user","COMPOSE_PROJECT_NAME":"some_project","PDF_PORT":"5000","DB_NAME":"database","DEV_CDN_PORT":"8899","DB_USERNAME":"user","PKG_CONFIG_PATH":"/3rd_party/breakpad/lib/pkgconfig:","CCACHE_SLOPPINESS":"pch_defines,time_macros","CONAN_REVISIONS_ENABLED":"1","PATH":"/vscode/vscode-server/bin/linux-x64/e10f2369d0d9614a452462f2e01cdc4aa9486296/bin/remote-cli:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/py-utils/bin","SSH_KEY":"id_rsa","CONAN_USER_HOME":"/tmp","DEV_APP_PORT":"7788","LANG":"C.UTF-8","PSQL_VERSION_MAJOR":"16","SHELL":"/bin/bash","FRONTEND_HTTP_PORT":"8080","CMAKE_CXX_COMPILER_LAUNCHER":"ccache","FRONTEND_CONTEXT":"git@gitlab.example.com:company/project-web.git","LC_ALL":"C.UTF-8","REDIS_HOST":"redis","DB_PASSWORD":"password","PWD":"/vscode/vscode-server/bin/linux-x64/e10f2369d0d9614a452462f2e01cdc4aa9486296","DB_HOST":"postgres","DEV_SSH_PORT":"2222","MS_PDFSERVICE_URL":"http://pdf:5000","PSQL_VERSION_MINOR":"3","VSCODE_CWD":"/vscode/vscode-server/bin/linux-x64/e10f2369d0d9614a452462f2e01cdc4aa9486296","VSCODE_NLS_CONFIG":"{\"userLocale\":\"en\",\"osLocale\":\"en\",\"resolvedLanguage\":\"en\",\"defaultMessagesFile\":\"/vscode/vscode-server/bin/linux-x64/e10f2369d0d9614a452462f2e01cdc4aa9486296/out/nls.messages.json\",\"locale\":\"en\",\"availableLanguages\":{}}","VSCODE_HANDLES_SIGPIPE":"true","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","REMOTE_CONTAINERS_IPC":"/tmp/vscode-remote-containers-ipc-9719b5b5-f148-4721-9b8d-defba683c085.sock","PIPX_BIN_DIR":"/usr/local/py-utils/bin","LS_COLORS":"","LESSCLOSE":"/usr/bin/lesspipe %s %s","REMOTE_CONTAINERS_SOCKETS":"[\"/tmp/vscode-ssh-auth-9719b5b5-f148-4721-9b8d-defba683c085.sock\",\"/tmp/.X11-unix/X15\",\"/home/dev_user/.gnupg/S.gpg-agent\"]","LESSOPEN":"| /usr/bin/lesspipe %s","PIPX_HOME":"/usr/local/py-utils","SHLVL":"1","_":"/usr/bin/cat","SSH_AUTH_SOCK":"/tmp/vscode-ssh-auth-9719b5b5-f148-4721-9b8d-defba683c085.sock","DISPLAY":":15","REMOTE_CONTAINERS_DISPLAY_SOCK":"/tmp/.X11-unix/X15","REMOTE_CONTAINERS":"true","BROWSER":"/vscode/vscode-server/bin/linux-x64/e10f2369d0d9614a452462f2e01cdc4aa9486296/bin/helpers/browser.sh","ELECTRON_RUN_AS_NODE":"1","VSCODE_IPC_HOOK_CLI":"/tmp/vscode-ipc-87eacdfd-54a6-4709-8956-14629172d68f.sock","VSCODE_L10N_BUNDLE_LOCATION":""}
[build] [0/1] Running clang-tidy...
[build] Enabled checks:
[build]     bugprone-assert-side-effect
[build]     bugprone-bad-signal-to-kill-thread
[build]     bugprone-bool-pointer-implicit-conversion
[build]     bugprone-branch-clone
[build]     bugprone-copy-constructor-init
[build]     bugprone-dangling-handle
[build]     bugprone-dynamic-static-initializers
[build]     bugprone-exception-escape
[build]     bugprone-fold-init-type
[build]     bugprone-forward-declaration-namespace
[build]     bugprone-forwarding-reference-overload
[build]     bugprone-implicit-widening-of-multiplication-result
[build]     bugprone-inaccurate-erase
[build]     bugprone-incorrect-roundings
[build]     bugprone-infinite-loop
[build]     bugprone-integer-division
[build]     bugprone-lambda-function-name
[build]     bugprone-macro-parentheses
[build]     bugprone-macro-repeated-side-effects
[build]     bugprone-misplaced-operator-in-strlen-in-alloc
[build]     bugprone-misplaced-pointer-arithmetic-in-alloc
[build]     bugprone-misplaced-widening-cast
[build]     bugprone-move-forwarding-reference
[build]     bugprone-multiple-statement-macro
[build]     bugprone-no-escape
[build]     bugprone-not-null-terminated-result
[build]     bugprone-parent-virtual-call
[build]     bugprone-posix-return
[build]     bugprone-redundant-branch-condition
[build]     bugprone-reserved-identifier
[build]     bugprone-signal-handler
[build]     bugprone-signed-char-misuse
[build]     bugprone-sizeof-container
[build]     bugprone-sizeof-expression
[build]     bugprone-spuriously-wake-up-functions
[build]     bugprone-string-constructor
[build]     bugprone-string-integer-assignment
[build]     bugprone-string-literal-with-embedded-nul
[build]     bugprone-stringview-nullptr
[build]     bugprone-suspicious-enum-usage
[build]     bugprone-suspicious-include
[build]     bugprone-suspicious-memory-comparison
[build]     bugprone-suspicious-memset-usage
[build]     bugprone-suspicious-missing-comma
[build]     bugprone-suspicious-semicolon
[build]     bugprone-suspicious-string-compare
[build]     bugprone-swapped-arguments
[build]     bugprone-terminating-continue
[build]     bugprone-throw-keyword-missing
[build]     bugprone-too-small-loop-variable
[build]     bugprone-undefined-memory-manipulation
[build]     bugprone-undelegated-constructor
[build]     bugprone-unhandled-exception-at-new
[build]     bugprone-unhandled-self-assignment
[build]     bugprone-unused-raii
[build]     bugprone-unused-return-value
[build]     bugprone-use-after-move
[build]     bugprone-virtual-near-miss
[build]     cert-dcl50-cpp
[build]     cert-dcl58-cpp
[build]     cert-env33-c
[build]     cert-err33-c
[build]     cert-err34-c
[build]     cert-err52-cpp
[build]     cert-err60-cpp
[build]     cert-flp30-c
[build]     cert-mem57-cpp
[build]     cert-msc50-cpp
[build]     cert-oop57-cpp
[build]     cert-oop58-cpp
[build]     concurrency-mt-unsafe
[build]     concurrency-thread-canceltype-asynchronous
[build]     cppcoreguidelines-avoid-goto
[build]     cppcoreguidelines-interfaces-global-init
[build]     cppcoreguidelines-no-malloc
[build]     cppcoreguidelines-prefer-member-initializer
[build]     cppcoreguidelines-pro-bounds-constant-array-index
[build]     cppcoreguidelines-pro-type-const-cast
[build]     cppcoreguidelines-pro-type-cstyle-cast
[build]     cppcoreguidelines-pro-type-member-init
[build]     cppcoreguidelines-pro-type-static-cast-downcast
[build]     cppcoreguidelines-pro-type-union-access
[build]     cppcoreguidelines-pro-type-vararg
[build]     cppcoreguidelines-slicing
[build]     cppcoreguidelines-virtual-class-destructor
[build]     google-build-explicit-make-pair
[build]     google-build-namespaces
[build]     google-build-using-namespace
[build]     google-explicit-constructor
[build]     google-global-names-in-headers
[build]     google-readability-avoid-underscore-in-googletest-name
[build]     google-readability-casting
[build]     google-runtime-int
[build]     google-runtime-operator
[build]     google-upgrade-googletest-case
[build]     hicpp-exception-baseclass
[build]     hicpp-no-assembler
[build]     misc-definitions-in-headers
[build]     misc-misleading-bidirectional
[build]     misc-misleading-identifier
[build]     misc-misplaced-const
[build]     misc-new-delete-overloads
[build]     misc-non-copyable-objects
[build]     misc-non-private-member-variables-in-classes
[build]     misc-redundant-expression
[build]     misc-static-assert
[build]     misc-throw-by-value-catch-by-reference
[build]     misc-unconventional-assign-operator
[build]     misc-uniqueptr-reset-release
[build]     misc-unused-alias-decls
[build]     misc-unused-parameters
[build]     misc-unused-using-decls
[build]     modernize-avoid-bind
[build]     modernize-concat-nested-namespaces
[build]     modernize-deprecated-headers
[build]     modernize-deprecated-ios-base-aliases
[build]     modernize-loop-convert
[build]     modernize-make-shared
[build]     modernize-make-unique
[build]     modernize-raw-string-literal
[build]     modernize-redundant-void-arg
[build]     modernize-replace-auto-ptr
[build]     modernize-replace-random-shuffle
[build]     modernize-return-braced-init-list
[build]     modernize-shrink-to-fit
[build]     modernize-unary-static-assert
[build]     modernize-use-bool-literals
[build]     modernize-use-default-member-init
[build]     modernize-use-emplace
[build]     modernize-use-equals-default
[build]     modernize-use-equals-delete
[build]     modernize-use-noexcept
[build]     modernize-use-nullptr
[build]     modernize-use-override
[build]     modernize-use-uncaught-exceptions
[build]     modernize-use-using
[build]     performance-faster-string-find
[build]     performance-for-range-copy
[build]     performance-implicit-conversion-in-loop
[build]     performance-inefficient-algorithm
[build]     performance-inefficient-string-concatenation
[build]     performance-inefficient-vector-operation
[build]     performance-move-const-arg
[build]     performance-move-constructor-init
[build]     performance-no-int-to-ptr
[build]     performance-noexcept-move-constructor
[build]     performance-type-promotion-in-math-fn
[build]     performance-unnecessary-copy-initialization
[build]     performance-unnecessary-value-param
[build]     readability-braces-around-statements
[build]     readability-const-return-type
[build]     readability-container-contains
[build]     readability-container-data-pointer
[build]     readability-container-size-empty
[build]     readability-delete-null-pointer
[build]     readability-duplicate-include
[build]     readability-function-size
[build]     readability-identifier-naming
[build]     readability-implicit-bool-conversion
[build]     readability-inconsistent-declaration-parameter-name
[build]     readability-isolate-declaration
[build]     readability-make-member-function-const
[build]     readability-misleading-indentation
[build]     readability-misplaced-array-index
[build]     readability-named-parameter
[build]     readability-non-const-parameter
[build]     readability-redundant-control-flow
[build]     readability-redundant-declaration
[build]     readability-redundant-function-ptr-dereference
[build]     readability-redundant-preprocessor
[build]     readability-redundant-smartptr-get
[build]     readability-redundant-string-cstr
[build]     readability-redundant-string-init
[build]     readability-simplify-boolean-expr
[build]     readability-static-accessed-through-instance
[build]     readability-string-compare
[build]     readability-suspicious-call-argument
[build]     readability-uniqueptr-delete-release
[build] 
[build] clang-apply-replacements version 14.0.0
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmpzbguybqk.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/db/src/data/foo.cpp
[build] 63723 warnings generated.
[build] Suppressed 63755 warnings (63723 in non-user code, 32 NOLINT).
[build] Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmp_hklgfue.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/http/src/foo.cpp
[build] 58152 warnings generated.
[build] Suppressed 58189 warnings (58152 in non-user code, 37 NOLINT).
[build] Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmp8v02lilk.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/db/src/data/foo.cpp
[build] 63841 warnings generated.
[build] Suppressed 63875 warnings (63841 in non-user code, 34 NOLINT).
[build] Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmpltgrvkne.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/db/src/foo.cpp
[build] 64009 warnings generated.
[build] Suppressed 64041 warnings (64009 in non-user code, 32 NOLINT).
[build] Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmpvxa1e60_.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/db/src/data/foo.cpp
[build] 63874 warnings generated.
[build] Suppressed 63908 warnings (63874 in non-user code, 34 NOLINT).
[build] Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmp7nmmpdyo.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/db/src/foo.cpp
[build] 64088 warnings generated.
[build] Suppressed 64120 warnings (64088 in non-user code, 32 NOLINT).
[build] Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmpixufpaav.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/db/src/data/foo.cpp
[build] 63924 warnings generated.
[build] Suppressed 63958 warnings (63924 in non-user code, 34 NOLINT).
[build] Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmplx1yft0e.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/db/src/data/foo.cpp
[build] 63920 warnings generated.
[build] Suppressed 63954 warnings (63920 in non-user code, 34 NOLINT).
[build] Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmphycv_9uk.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/http/src/handlers/foo.cpp
[build] 60988 warnings generated.
[build] Suppressed 61025 warnings (60988 in non-user code, 37 NOLINT).
[build] Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmplblaafiq.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/foo/src/buy/yapily/foo.cpp
[build] 66633 warnings generated.
[build] Suppressed 66668 warnings (66633 in non-user code, 35 NOLINT).
[build] Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmp5frky4n7.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/foo/src/foo.cpp
[build] 66576 warnings generated.
[build] Suppressed 66611 warnings (66576 in non-user code, 35 NOLINT).
[build] Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmpc05nmwyy.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/foo/src/buy/pspSelector/foo.cpp
[build] 66705 warnings generated.
[build] Suppressed 66740 warnings (66705 in non-user code, 35 NOLINT).
[build] Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
[extension] [1206] cmake.stop started
[proc] The command: pgrep -P 3082 exited with code: 1
[proc] The command: pgrep -P 3083 exited with code: 1
[proc] The command: pgrep -P 3085 exited with code: 1
[proc] The command: pgrep -P 3088 exited with code: 1
[proc] The command: pgrep -P 3222 exited with code: 1
[proc] The command: pgrep -P 3229 exited with code: 1
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmpmyhex9tk.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/foo/src/foo.cpp
[build] /home/dev_user/some_project/modules/foo/src/foo.cpp: terminated by signal 2
[proc] The command: pgrep -P 3230 exited with code: 1
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmp75f95tri.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/foo/src/foo.cpp
[build] /home/dev_user/some_project/modules/foo/src/foo.cpp: terminated by signal 2
[proc] The command: pgrep -P 3231 exited with code: 1
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmpn_kj32rp.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/utils/src/foo.cpp
[build] /home/dev_user/some_project/modules/utils/src/foo.cpp: terminated by signal 2
[proc] The command: pgrep -P 3232 exited with code: 1
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmp45gx0jmt.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/foo/src/foo.cpp
[build] /home/dev_user/some_project/modules/foo/src/foo.cpp: terminated by signal 2
[proc] The command: pgrep -P 3233 exited with code: 1
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmp4twyaxr0.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/view/src/foo.cpp
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmp5i2phd3p.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/db/src/foo.cpp
[build] /home/dev_user/some_project/modules/view/src/foo.cpp: terminated by signal 2
[build] /home/dev_user/some_project/modules/db/src/foo.cpp: terminated by signal 2
[proc] The command: pgrep -P 3240 exited with code: 1
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmpct3tnkt4.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/db/src/foo.cpp
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmpnjdwlm8x.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/db/src/foo.cpp
[build] /home/dev_user/some_project/modules/db/src/foo.cpp: terminated by signal 2
[build] /home/dev_user/some_project/modules/db/src/foo.cpp: terminated by signal 2
[proc] The command: pgrep -P 3241 exited with code: 1
[build] /usr/bin/clang-tidy-14 --use-color -export-fixes /tmp/tmpodkw0red/tmplzoypnws.yaml -p=/home/dev_user/some_project/build /home/dev_user/some_project/modules/foo/src/foo.cpp
[build] /home/dev_user/some_project/modules/foo/src/foo.cpp: terminated by signal 2
[proc] The command: pgrep -P 3248 exited with code: 1
[proc] The command: pgrep -P 3261 exited with code: 1
[proc] The command: pgrep -P 3262 exited with code: 1

Additional Information

The project also uses CMakePresets.json, here is the relevant part:

{
  "version": 8,
  "configurePresets": [
    {
      "name": "base",
      "hidden": true,
      "binaryDir": "${sourceDir}/build",
      "generator": "Ninja",
      "cacheVariables": {
        "CMAKE_EXPORT_COMPILE_COMMANDS": true
      }
    },
    {
      "name": "release",
      "inherits": "base",
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Release"
      }
    },
    {
      "name": "analysis",
      "inherits": "release",
      "cacheVariables": {
        "ENABLE_CLANG_TIDY": true
      }
    }
  ],
  "buildPresets": [
    {
      "name": "analysis",
      "configurePreset": "analysis",
      "targets": [ "clang-tidy" ]
    }
  ]
}
v-frankwang commented 14 hours ago

@i-ky Thanks for posting this issue. Are you able to provide a simple reproduction project to help us quickly investigate this issue?:)