[clang-check][syntax] Crash in Node::assertInvariants: in Assertion `C.getRole() == NodeRole::ListElement || C.getRole() == NodeRole::ListDelimiter' `failed.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
This is generated by a fuzzer.
```cxx
struct foo{};
struct X{};
void captureStringView(foo s [[clang::lifetime_capture_by(x)]], X &x);
```
```
clang-check --tokens-dump example.cpp -- -xc++ -std=c++23
```
```
clang-check: /home/ubuntu2404/llvm-project-196067/clang/lib/Tooling/Syntax/Tree.cpp:264: void clang::syntax::Node::assertInvariants() const: Assertion `C.getRole() == NodeRole::ListElement || C.getRole() == NodeRole::ListDelimiter' failed.
#0 0x00005bfb493a91f1 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/ubuntu2404/build-196067-assert/bin/clang-check+0x96d1f1)
#1 0x00005bfb493a5dac llvm::sys::RunSignalHandlers() (/home/ubuntu2404/build-196067-assert/bin/clang-check+0x969dac)
#2 0x00005bfb493a5f0c SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x000078c6e5445330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#4 0x000078c6e549eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x000078c6e549eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x000078c6e549eb2c pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x000078c6e544527e raise ./signal/../sysdeps/posix/raise.c:27:6
#8 0x000078c6e54288ff abort ./stdlib/abort.c:81:7
#9 0x000078c6e542881b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x000078c6e543b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#11 0x00005bfb4976d613 clang::syntax::Node::assertInvariants() const (/home/ubuntu2404/build-196067-assert/bin/clang-check+0xd31613)
#12 0x00005bfb4976d83d (anonymous namespace)::traverse(clang::syntax::Node const*, llvm::function_ref) (.constprop.0) Tree.cpp:0:0
#13 0x00005bfb4976da03 clang::syntax::Node::assertInvariantsRecursive() const (/home/ubuntu2404/build-196067-assert/bin/clang-check+0xd31a03)
#14 0x00005bfb497484fa clang::syntax::buildSyntaxTree(clang::syntax::Arena&, clang::syntax::TokenBufferTokenManager&, clang::ASTContext&) (/home/ubuntu2404/build-196067-assert/bin/clang-check+0xd0c4fa)
#15 0x00005bfb48e3c4af (anonymous namespace)::DumpSyntaxTree::CreateASTConsumer(clang::CompilerInstance&, llvm::StringRef)::Consumer::HandleTranslationUnit(clang::ASTContext&) ClangCheck.cpp:0:0
#16 0x00005bfb4ac72f9c clang::ParseAST(clang::Sema&, bool, bool) (/home/ubuntu2404/build-196067-assert/bin/clang-check+0x2236f9c)
#17 0x00005bfb49400271 clang::FrontendAction::Execute() (/home/ubuntu2404/build-196067-assert/bin/clang-check+0x9c4271)
#18 0x00005bfb4944c308 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/ubuntu2404/build-196067-assert/bin/clang-check+0xa10308)
#19 0x00005bfb49728cb7 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr, clang::FileManager*, std::shared_ptr, clang::DiagnosticConsumer*) (/home/ubuntu2404/build-196067-assert/bin/clang-check+0xceccb7)
#20 0x00005bfb49722b2a clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr, std::shared_ptr) (/home/ubuntu2404/build-196067-assert/bin/clang-check+0xce6b2a)
#21 0x00005bfb497251e2 clang::tooling::ToolInvocation::run() (/home/ubuntu2404/build-196067-assert/bin/clang-check+0xce91e2)
#22 0x00005bfb49726e19 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/home/ubuntu2404/build-196067-assert/bin/clang-check+0xceae19)
#23 0x00005bfb48dc1405 main (/home/ubuntu2404/build-196067-assert/bin/clang-check+0x385405)
#24 0x000078c6e542a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#25 0x000078c6e542a28b call_init ./csu/../csu/libc-start.c:128:20
#26 0x000078c6e542a28b __libc_start_main ./csu/../csu/libc-start.c:347:5
#27 0x00005bfb48e3b045 _start (/home/ubuntu2404/build-196067-assert/bin/clang-check+0x3ff045)
Aborted (core dumped)
```
Contributor guide
Research direction
Reproduce the crash with clang-check --tokens-dump using the C++ example and compiler flags in the issue. Start at clang/lib/Tooling/Syntax/Tree.cpp:264 and trace the syntax-tree construction reached from buildSyntaxTree; done means the reproducer no longer aborts in Node::assertInvariants.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100