Upgrade clang-tools to 21 to fix clangd SIGSEGV on CUDA files#491
Upgrade clang-tools to 21 to fix clangd SIGSEGV on CUDA files#491fwilliams wants to merge 1 commit intoopenvdb:mainfrom
Conversation
clangd 18 crashes (SIGSEGV) when building ASTs for .cuh files compiled in CUDA mode. The crash occurs in Sema::MarkFunctionReferenced via Sema::ActOnCXXDelete when parsing `delete this;` in GCC 13.4.0's locale_classes.h (std::locale::facet::_M_remove_reference). This is a known clang 18 bug in CUDA host/device operator-delete resolution that is fixed in later versions. Bump clang-tools from 18 to 21 so the fvdb conda environment ships a working clangd. Because clang-tools=21 depends on clang-format=21, switch the clang-format and clang specs to the versioned package names (clang-format-18, clang-18) which coexist alongside the new metapackages and keep the clang-format-18 binary available as required by CI. Signed-off-by: Francis Williams <francis@fwilliams.info> Made-with: Cursor
|
Why not use clang-tools 21 in CI as well? |
I think what's being relayed is that we are leaving the 'C++ codestyle' action in |
swahtz
left a comment
There was a problem hiding this comment.
I tried it out and works well for me, thanks for fixing that up.
|
Actually I'm finding that vscode/cursor is changing the formatting of C++ source files with this |
swahtz
left a comment
There was a problem hiding this comment.
I found that without changing the path to the clang-format-18 tool, we were getting source files reformatted with the wrong clang-format version. If you can apply this patch, I found this should fix that situation:
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 0015bbb..f81ee57 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -58,7 +58,7 @@
"json.format.keepLines": true,
"clangd.path": "${env:CONDA_PREFIX}/envs/fvdb/bin/clangd",
- "clangFormat.executable.linux": "${env.CONDA_PREFIX}/envs/fvdb/bin/clang-format",
+ "clangFormat.executable.linux": "${env.CONDA_PREFIX}/envs/fvdb/bin/clang-format-18",
"cursorpyright.analysis.diagnosticSeverityOverrides": {
"reportPrivateImportUsage": "none"
},
Summary
clang-toolsfrom 18 to 21 in the dev conda environment to fix aclangdcrash (SIGSEGV) that occurs when building ASTs for.cuhfiles.operator deleteresolution, triggered bydelete this;in GCC 13.4.0'slocale_classes.h(std::locale::facet::_M_remove_reference). It is fixed in clang 21.clang-formatandclangspecs to versioned package names (clang-format-18,clang-18) so they coexist with theclang-tools=21dependency onclang-format=21. Theclang-format-18binary remains available as required by CI.Motivation
clangd(shipped viaclang-tools) crashes with a segmentation fault every time it tries to parse CUDA files that transitively include GCC's<locale>header (e.g. via PyTorch or standard library headers). This makes C++/CUDA language intelligence completely non-functional for affected files likeGaussianCameras.cuh.The crash stack trace:
Upgrading to clang-tools 21 (which bundles clangd 21) resolves the crash since the underlying CUDA
operator deleteresolution bug was fixed upstream.Test plan
clangd --check=src/fvdb/detail/ops/gsplat/GaussianCameras.cuhcompletes without crash on clangd 21clang-format-18 --versionstill reports 18.1.8 after the environment rebuildenv/dev_environment.ymland confirm clangd no longer crashes on CUDA filesMade with Cursor