Skip to content

Clang assertion failure at -O2 "Assertion `!Info.isIncomplete() && "Access to an object of an incomplete type!"' failed." #149021

@bi6c

Description

@bi6c

Compiler Explorer: https://godbolt.org/z/q68Wh7acT

  • generated by fuzzer

console:

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 -fno-verbose-asm -c --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O2 <source>
1.	<eof> parser at end of file
2.	<source>:17:6: LLVM IR generation of declaration 'g'
3.	<source>:17:6: Generating code for declaration 'g'
 #0 0x0000000003fb0ae8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fb0ae8)
 #1 0x0000000003fadf14 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fadf14)
 #2 0x0000000003ef26e8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007abd8fe42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007abd8fe969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007abd8fe42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007abd8fe287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007abd8fe2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007abd8fe39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x00000000045c71b8 clang::CodeGen::CodeGenTBAA::getAccessTagInfo(clang::CodeGen::TBAAAccessInfo) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45c71b8)
#10 0x000000000451e860 clang::CodeGen::CodeGenModule::DecorateInstructionWithTBAA(llvm::Instruction*, clang::CodeGen::TBAAAccessInfo) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x451e860)
#11 0x00000000042fd903 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+0x42fd903)
#12 0x00000000042fe915 clang::CodeGen::CodeGenFunction::EmitLoadOfLValue(clang::CodeGen::LValue, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42fe915)
#13 0x0000000004388476 (anonymous namespace)::ScalarExprEmitter::EmitLoadOfLValue(clang::Expr const*) CGExprScalar.cpp:0:0
#14 0x0000000004382b77 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#15 0x00000000043854bc clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x43854bc)
#16 0x00000000042eb9ee clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42eb9ee)
#17 0x00000000043191ed clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x43191ed)
#18 0x00000000044920f7 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44920f7)
#19 0x0000000004499970 clang::CodeGen::CodeGenFunction::EmitIfStmt(clang::IfStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4499970)
#20 0x000000000449232e clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x449232e)
#21 0x000000000449a28c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x449a28c)
#22 0x00000000045012ae clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45012ae)
#23 0x0000000004512fa4 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4512fa4)
#24 0x000000000457dded clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x457dded)
#25 0x0000000004578df4 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4578df4)
#26 0x0000000004579493 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4579493)
#27 0x0000000004584023 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#28 0x000000000496a070 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#29 0x00000000049596b4 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49596b4)
#30 0x000000000665f964 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x665f964)
#31 0x0000000004965d28 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4965d28)
#32 0x0000000004c5fa55 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c5fa55)
#33 0x0000000004bdc73e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4bdc73e)
#34 0x0000000004d51891 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4d51891)
#35 0x0000000000d93aef cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd93aef)
#36 0x0000000000d8a6ca ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#37 0x00000000049cce79 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
#38 0x0000000003ef2b84 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ef2b84)
#39 0x00000000049cd48f 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
#40 0x000000000498f45d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x498f45d)
#41 0x00000000049904ee 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+0x49904ee)
#42 0x0000000004999085 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4999085)
#43 0x0000000000d8ff9f clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd8ff9f)
#44 0x0000000000c44cb4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc44cb4)
#45 0x00007abd8fe29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#46 0x00007abd8fe29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#47 0x0000000000d8a175 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd8a175)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134

Code:

#define t short int
#define op -

#ifndef t
#define t long long
#endif
#ifndef t2
#define t2 t
#endif
#ifndef op
#define op -
#endif

extern void foo;

void g(t a, t b) {
  t2 c = a op b;

  if (c >= 0)
    foo;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:codegenIR generation bugs: mangling, exceptions, etc.crashPrefer [crash-on-valid] or [crash-on-invalid]duplicateResolved as duplicategenerated by fuzzer

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions