Issue 143091
Summary Clang-21 Crash: Assertion `!Info.isIncomplete() && "Access to an object of an incomplete type!"' failed.
Labels new issue
Assignees
Reporter hyf751175784
    ### Description
I encountered a crash in Clang-21 when compiling the following code with compilation options:
```c
enum E e;

void
foo (void)
{
  int a[e];
}
```
Options:
```sh
-Os -fno-stack-protector -march=atom -mno-sse2  
```

### Clang Version

```sh
$ clang -v
Ubuntu clang version 21.0.0 (++20250501082025+9b1051281e43-1~exp1~20250501082214.882)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-21/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Candidate multilib: .;@m64
Selected multilib: .;@m64
```

### Command
The compilation command used was:
```sh
clang bug.c -Os -fno-stack-protector -march=atom -mno-sse2  -c -o bug.o
```

### Error Message
```sh
clang: /root/llvm-project/llvm/tools/clang/lib/CodeGen/CodeGenTBAA.cpp:624: llvm::MDNode* clang::CodeGen::CodeGenTBAA::getAccessTagInfo(clang::CodeGen::TBAAAccessInfo): Assertion `!Info.isIncomplete() && "Access to an object of an incomplete type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -Os -fno-stack-protector -march=atom -mno-sse2 <source>
1.	<eof> parser at end of file
2.	<source>:4:1: LLVM IR generation of declaration 'foo'
3.	<source>:4:1: Generating code for declaration 'foo'
 #0 0x0000000003fdf498 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fdf498)
 #1 0x0000000003fdd124 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fdd124)
 #2 0x0000000003f21e88 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f7a69842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f7a698969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007f7a69842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007f7a698287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007f7a6982871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007f7a69839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x00000000045f6f09 clang::CodeGen::CodeGenTBAA::getAccessTagInfo(clang::CodeGen::TBAAAccessInfo) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45f6f09)
#10 0x000000000454ee70 clang::CodeGen::CodeGenModule::DecorateInstructionWithTBAA(llvm::Instruction*, clang::CodeGen::TBAAAccessInfo) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x454ee70)
#11 0x0000000004330033 clang::CodeGen::CodeGenFunction::EmitLoadOfScalar(clang::CodeGen::Address, bool, clang::QualType, clang::SourceLocation, clang::CodeGen::LValueBaseInfo, clang::CodeGen::TBAAAccessInfo, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4330033)
#12 0x0000000004331035 clang::CodeGen::CodeGenFunction::EmitLoadOfLValue(clang::CodeGen::LValue, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4331035)
#13 0x00000000043bc116 (anonymous namespace)::ScalarExprEmitter::EmitLoadOfLValue(clang::Expr const*) CGExprScalar.cpp:0:0
#14 0x00000000043b50d7 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#15 0x00000000043b546b (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#16 0x00000000043bc69b (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) CGExprScalar.cpp:0:0
#17 0x00000000043b3661 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#18 0x00000000043b91ac clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x43b91ac)
#19 0x000000000453b34f clang::CodeGen::CodeGenFunction::EmitVariablyModifiedType(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x453b34f)
#20 0x00000000048ef088 clang::CodeGen::CodeGenFunction::EmitAutoVarAlloca(clang::VarDecl const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x48ef088)
#21 0x00000000048f33db clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (.part.0) CGDecl.cpp:0:0
#22 0x00000000048f3be7 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x48f3be7)
#23 0x00000000044b4cec clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44b4cec)
#24 0x00000000044cac92 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44cac92)
#25 0x00000000044c25d1 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44c25d1)
#26 0x00000000044ca72c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44ca72c)
#27 0x000000000453053e clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x453053e)
#28 0x0000000004543814 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4543814)
#29 0x00000000045adc6d clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45adc6d)
#30 0x00000000045a8c84 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45a8c84)
#31 0x00000000045a9333 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45a9333)
#32 0x00000000045b3e53 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#33 0x0000000004998b76 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#34 0x0000000004988654 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4988654)
#35 0x000000000668c484 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x668c484)
#36 0x0000000004994d08 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4994d08)
#37 0x0000000004c8ede5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c8ede5)
#38 0x0000000004c0c0ee clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c0c0ee)
#39 0x0000000004d81149 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4d81149)
#40 0x0000000000dbc0cf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdbc0cf)
#41 0x0000000000db2cda ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#42 0x00000000049fbd59 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#43 0x0000000003f22324 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f22324)
#44 0x00000000049fc36f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#45 0x00000000049bdebd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49bdebd)
#46 0x00000000049bef4e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49bef4e)
#47 0x00000000049c7045 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49c7045)
#48 0x0000000000db85df clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdb85df)
#49 0x0000000000c3ba44 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc3ba44)
#50 0x00007f7a69829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#51 0x00007f7a69829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#52 0x0000000000db2785 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdb2785)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```

The issue can also be reproduced on Compiler Explorer:https://godbolt.org/z/caj1vP5M3
Please let me know if you need any more details.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to