[clangd][HLSL]didOpen-only triggers assertion `DD && queried property of class with no definition` related to HLSL
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
The reduced input was produced from [clang/test/AST/HLSL/resources-in-structs.hlsl.](https://github.com/llvm/llvm-project/blob/main/clang/test/AST/HLSL/resources-in-structs.hlsl).
The crash is triggered by a valid `textDocument/didOpen` request in clangd. No extra LSP request is required.
minimal input:
```hlsl
class {
SamplerState a
}
```
```
I[01:05:19.829] clangd version 23.0.0git (https://github.com/llvm/llvm-project.git c75e1e62d11be965a4dca0d816a4d19a6684b043)
I[01:05:19.829] Features: linux+debug-tidy
I[01:05:19.829] PID: 30989
I[01:05:19.829] Working directory: /harness/cases/CASE-20260514-018/workspace
I[01:05:19.829] argv[0]: /tmp/build-assert-clangd-main-20260506/bin/clangd
I[01:05:19.829] argv[1]: --background-index=0
I[01:05:19.829] argv[2]: --clang-tidy=0
I[01:05:19.829] Starting LSP over stdin/stdout
I[01:05:19.835] <-- initialize(1)
I[01:05:19.836] --> reply:initialize(1) 0 ms
Content-Length: 2077
{"id":1,"jsonrpc":"2.0","result":{"capabilities":{"astProvider":true,"callHierarchyProvider":true,"clangdInlayHintsProvider":true,"codeActionProvider":true,"compilationDatabase":{"automaticReload":true},"completionProvider":{"resolveProvider":false,"triggerCharacters":[".","<",">",":","\"","/","*"]},"declarationProvider":true,"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentLinkProvider":{"resolveProvider":false},"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"\n","moreTriggerCharacter":[]},"documentRangeFormattingProvider":{"rangesSupport":true},"documentSymbolProvider":true,"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyRename","clangd.applyTweak"]},"foldingRangeProvider":true,"hoverProvider":true,"implementationProvider":true,"inactiveRegionsProvider":true,"inlayHintProvider":true,"memoryUsageProvider":true,"referencesProvider":true,"renameProvider":true,"selectionRangeProvider":true,"semanticTokensProvider":{"full":{"delta":true},"legend":{"tokenModifiers":["declaration","definition","deprecated","deduced","readonly","static","abstract","virtual","dependentName","defaultLibrary","usedAsMutableReference","usedAsMutablePointer","constructorOrDestructor","userDefined","functionScope","classScope","fileScope","globalScope"],"tokenTypes":["variable","variable","parameter","function","method","function","property","variable","class","interface","enum","enumMember","type","type","unknown","namespace","typeParameter","concept","type","macro","modifier","operator","bracket","label","comment"]},"range":false},"signatureHelpProvider":{"triggerCharacters":["(",")","{","}","<",">",","]},"standardTypeHierarchyProvider":true,"textDocumentSync":{"change":2,"openClose":true,"save":true},"typeDefinitionProvider":true,"typeHierarchyProvider":true,"workspaceSymbolProvider":true},"serverInfo":{"name":"clangd","version":"clangd version 23.0.0git (https://github.com/llvm/llvm-project.git c75e1e62d11be965a4dca0d816a4d19a6684b043) linux+debug-tidy x86_64-unknown-linux-gnu"}}}I[01:05:19.847] <-- initialized
I[01:05:19.858] <-- textDocument/didOpen
I[01:05:19.859] Loaded compilation database from /harness/cases/CASE-20260514-018/workspace/compile_commands.json
I[01:05:19.859] ASTWorker building file /harness/cases/CASE-20260514-018/workspace/resources-in-structs.hlsl version 1 with command
[/harness/cases/CASE-20260514-018/workspace]
/usr/lib/llvm-18/bin/clang -x hlsl -fsyntax-only -I/harness/cases/CASE-20260514-018/workspace/Inputs -resource-dir=/tmp/build-assert-clangd-main-20260506/lib/clang/23 -- /harness/cases/CASE-20260514-018/workspace/resources-in-structs.hlsl
I[01:05:19.915] Built preamble of size 1018252 for file /harness/cases/CASE-20260514-018/workspace/resources-in-structs.hlsl version 1 in 0.05 seconds
clangd: /tmp/llvm-project-main-20260504/clang/include/clang/AST/DeclCXX.h:463: clang::CXXRecordDecl::DefinitionData& clang::CXXRecordDecl::data() const: Assertion `DD && "queried property of class with no definition"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. parser at end of file
I[01:05:22.872] <-- shutdown(2)
I[01:05:22.872] --> reply:shutdown(2) 0 ms
Content-Length: 38
{"id":2,"jsonrpc":"2.0","result":null}I[01:05:22.882] <-- exit
I[01:05:22.882] LSP finished, exiting with status 0
#0 0x000056622b01a8f2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /tmp/llvm-project-main-20260504/llvm/lib/Support/Unix/Signals.inc:884:3
#1 0x000056622b01766c llvm::sys::RunSignalHandlers() /tmp/llvm-project-main-20260504/llvm/lib/Support/Signals.cpp:108:20
#2 0x000056622b017ee1 SignalHandler(int, siginfo_t*, void*) /tmp/llvm-project-main-20260504/llvm/lib/Support/Unix/Signals.inc:448:14
#3 0x00007aebb7645330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#4 0x00007aebb769eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007aebb769eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x00007aebb769eb2c pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x00007aebb764527e raise ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007aebb76288ff abort ./stdlib/abort.c:81:7
#9 0x00007aebb762881b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007aebb763b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#11 0x000056622b09c6bc decltype(auto) llvm::cast(clang::RecordDecl*) /tmp/llvm-project-main-20260504/clang/include/clang/AST/DeclCXX.h:463:5
#12 0x000056622b09c6bc clang::CXXRecordDecl::getMostRecentDecl() /tmp/llvm-project-main-20260504/clang/include/clang/AST/DeclCXX.h:540:31
#13 0x000056622b09c6bc clang::CXXRecordDecl::getMostRecentDecl() const /tmp/llvm-project-main-20260504/clang/include/clang/AST/DeclCXX.h:545:63
#14 0x000056622b09c6bc clang::CXXRecordDecl::dataPtr() const /tmp/llvm-project-main-20260504/clang/include/clang/AST/DeclCXX.h:457:22
#15 0x000056622b09c6bc clang::CXXRecordDecl::data() const /tmp/llvm-project-main-20260504/clang/include/clang/AST/DeclCXX.h:462:23
#16 0x000056622c144fbf hasConstantBufferLayout(clang::QualType) /tmp/llvm-project-main-20260504/clang/lib/Sema/SemaHLSL.cpp:4966:5
#17 0x000056622c144f90 hasConstantBufferLayout(clang::QualType) /tmp/llvm-project-main-20260504/clang/lib/Sema/SemaHLSL.cpp:4963:7
#18 0x000056622c15320d IsDefaultBufferConstantDecl /tmp/llvm-project-main-20260504/clang/lib/Sema/SemaHLSL.cpp:4991:68
#19 0x000056622c15320d clang::SemaHLSL::ActOnVariableDeclarator(clang::VarDecl*) /tmp/llvm-project-main-20260504/clang/lib/Sema/SemaHLSL.cpp:5320:36
#20 0x000056622bece984 clang::Sema::getLangOpts() const /tmp/llvm-project-main-20260504/clang/include/clang/Sema/Sema.h:932:51
#21 0x000056622bece984 clang::Sema::ActOnVariableDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef, bool&, llvm::ArrayRef) /tmp/llvm-project-main-20260504/clang/lib/Sema/SemaDecl.cpp:8251:18
#22 0x000056622bee6bb7 clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef) /tmp/llvm-project-main-20260504/clang/lib/Sema/SemaDecl.cpp:6663:34
#23 0x000056622bee73ac clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) /tmp/llvm-project-main-20260504/clang/lib/Sema/SemaDecl.cpp:6296:31
#24 0x000056622cec69cb clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) /tmp/llvm-project-main-20260504/clang/lib/Parse/ParseDecl.cpp:2585:18
#25 0x000056622ced8b02 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) /tmp/llvm-project-main-20260504/clang/lib/Parse/ParseDecl.cpp:2382:3
#26 0x000056622ce9a1f9 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /tmp/llvm-project-main-20260504/clang/lib/Parse/Parser.cpp:1153:73
#27 0x000056622ce9aa7f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /tmp/llvm-project-main-20260504/clang/lib/Parse/Parser.cpp:1175:42
#28 0x000056622cea1571 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /tmp/llvm-project-main-20260504/clang/lib/Parse/Parser.cpp:1003:50
#29 0x000056622cea3237 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) /tmp/llvm-project-main-20260504/clang/lib/Parse/Parser.cpp:711:36
#30 0x000056622cea36d3 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) /tmp/llvm-project-main-20260504/clang/lib/Parse/Parser.cpp:608:32
#31 0x000056622ce87aaa clang::ParseAST(clang::Sema&, bool, bool) /tmp/llvm-project-main-20260504/clang/lib/Parse/ParseAST.cpp:169:69
#32 0x000056622cc816e7 clang::FrontendAction::Execute() /tmp/llvm-project-main-20260504/clang/lib/Frontend/FrontendAction.cpp:1346:38
#33 0x000056622c66607c llvm::Error::getPtr() const /tmp/llvm-project-main-20260504/llvm/include/llvm/Support/Error.h:278:51
#34 0x000056622c66607c llvm::Error::operator bool() /tmp/llvm-project-main-20260504/llvm/include/llvm/Support/Error.h:241:22
#35 0x000056622c66607c clang::clangd::ParsedAST::build(llvm::StringRef, clang::clangd::ParseInputs const&, std::unique_ptr>, llvm::ArrayRef, std::shared_ptr) /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/ParsedAST.cpp:709:42
#36 0x000056622c70953c std::unique_ptr>::~unique_ptr() /usr/include/c++/13/bits/unique_ptr.h:403:12
#37 0x000056622c70953c clang::clangd::(anonymous namespace)::ASTWorker::generateDiagnostics(std::unique_ptr>, clang::clangd::ParseInputs, std::vector>) /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/TUScheduler.cpp:1214:74
#38 0x000056622c709f50 std::unique_ptr>::~unique_ptr() /usr/include/c++/13/bits/unique_ptr.h:403:12
#39 0x000056622c709f50 clang::clangd::(anonymous namespace)::ASTWorker::updatePreamble(std::unique_ptr>, clang::clangd::ParseInputs, std::shared_ptr, std::vector>, clang::clangd::WantDiagnostics)::'lambda'()::operator()() (.part.0) /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/TUScheduler.cpp:1147:24
#40 0x000056622c6fe2aa clang::clangd::(anonymous namespace)::ASTWorker::runTask(llvm::StringRef, llvm::function_ref) /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/TUScheduler.cpp:1328:1
#41 0x000056622c7019fa clang::clangd::(anonymous namespace)::ASTWorker::run() /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/TUScheduler.cpp:1462:5
#42 0x000056622c8e4b6e llvm::detail::UniqueFunctionBase::operator=(llvm::detail::UniqueFunctionBase&&) /tmp/llvm-project-main-20260504/llvm/include/llvm/ADT/FunctionExtras.h:329:5
#43 0x000056622c8e4b6e llvm::detail::UniqueFunctionBase::operator=(llvm::detail::UniqueFunctionBase&&) /tmp/llvm-project-main-20260504/llvm/include/llvm/ADT/FunctionExtras.h:321:23
#44 0x000056622c8e4b6e llvm::unique_function::operator=(llvm::unique_function&&) /tmp/llvm-project-main-20260504/llvm/include/llvm/ADT/FunctionExtras.h:352:20
#45 0x000056622c8e4b6e operator() /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/support/Threading.cpp:103:14
#46 0x000056622c8e4b6e operator())::&> /tmp/llvm-project-main-20260504/llvm/include/llvm/Support/thread.h:46:16
#47 0x000056622c8e4b6e __invoke_impl):: > >(void*)::, clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function)::&> /usr/include/c++/13/bits/invoke.h:61:36
#48 0x000056622c8e4b6e __invoke):: > >(void*)::, clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function)::&> /usr/include/c++/13/bits/invoke.h:96:40
#49 0x000056622c8e4b6e __apply_impl):: > >(void*)::, std::tuple):: >&, 0> /usr/include/c++/13/tuple:2302:27
#50 0x000056622c8e4b6e apply):: > >(void*)::, std::tuple):: >&> /usr/include/c++/13/tuple:2313:31
#51 0x000056622c8e4b6e GenericThreadProxy):: > > /tmp/llvm-project-main-20260504/llvm/include/llvm/Support/thread.h:44:15
#52 0x000056622c8e4b6e void* llvm::thread::ThreadProxy)::'lambda0'()>>(void*) /tmp/llvm-project-main-20260504/llvm/include/llvm/Support/thread.h:62:36
#53 0x00007aebb769caa4 start_thread ./nptl/pthread_create.c:447:8
#54 0x00007aebb7729c6c clone3 ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80:0
Signalled during AST worker action: Build AST
Filename: /harness/cases/CASE-20260514-018/workspace/resources-in-structs.hlsl
Directory: /harness/cases/CASE-20260514-018/workspace
Command Line: /usr/lib/llvm-18/bin/clang -x hlsl -fsyntax-only -I/harness/cases/CASE-20260514-018/workspace/Inputs -resource-dir=/tmp/build-assert-clangd-main-20260506/lib/clang/23 -- /harness/cases/CASE-20260514-018/workspace/resources-in-structs.hlsl
Version: 1
/harness/scripts/run_clangd_didopen_workspace.sh: line 91: 30988 Done { emit_lsp "$INIT"; emit_lsp "$INITIALIZED"; emit_lsp "$DIDOPEN"; sleep "$DIDOPEN_WAIT_SECS"; emit_lsp "$SHUTDOWN"; emit_lsp "$EXIT"; }
30989 Aborted (core dumped) | ( cd "$WORKDIR"; "$TARGET" "${TARGET_ARGS[@]}" )
```
Contributor guide
Research direction
Reproduce the assertion by sending only textDocument/didOpen for the minimal HLSL input. Start in clang/lib/Sema/SemaHLSL.cpp at hasConstantBufferLayout and IsDefaultBufferConstantDecl, then inspect the clangd AST-building path in clang-tools-extra/clangd/ParsedAST.cpp. Done means clangd handles this input without asserting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100