llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

clang: Assertion `Prior->FD->hasAttr<NoUniqueAddressAttr>() && "should not have reused this field's tail padding"' failed.

Open wierton opened this issue 1 year ago • 3 comments

The testcase (compiled with clang small.c):

struct T {
  short a;
  char b[~(__SIZE_TYPE__)0 / __CHAR_BIT__ - 1];
};

void c() { struct T d = {5}; }

Compiler Explorer: https://gcc.godbolt.org/z/hG8rsKhdP

Compiler Version:

clang version 17.0.0 (https://github.com/llvm/llvm-project.git 12e9c7aaa66b7624b5d7666ce2794d912bf9e4b7)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-assertions-trunk/bin
Compiler returned: 0

Compiler Assertion Message:

[$ clang small.c](clang: /root/llvm-project/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:758: void {anonymous}::CGRecordLowering::clipTailPadding(): Assertion `Prior->FD->hasAttr<NoUniqueAddressAttr>() && "should not have reused this field's tail padding"' failed.)

Backtrace:

Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics <source>
1.	<eof> parser at end of file
2.	<source>:6:6: LLVM IR generation of declaration 'c'
3.	<source>:6:6: Generating code for declaration 'c'
 #0 0x0000559891486f2f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c52f2f)
 #1 0x0000559891484c9c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c50c9c)
 #2 0x00005598913cf398 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007fb1fb05b420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007fb1fab2800b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007fb1fab07859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00007fb1fab07729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #7 0x00007fb1fab18fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #8 0x0000559891794e44 (anonymous namespace)::CGRecordLowering::clipTailPadding() CGRecordLayoutBuilder.cpp:0:0
 #9 0x000055989179ab13 (anonymous namespace)::CGRecordLowering::lower(bool) CGRecordLayoutBuilder.cpp:0:0
#10 0x000055989179ddf2 clang::CodeGen::CodeGenTypes::ComputeRecordLayout(clang::RecordDecl const*, llvm::StructType*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f69df2)
#11 0x00005598918d6727 clang::CodeGen::CodeGenTypes::ConvertRecordDeclType(clang::RecordDecl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x40a2727)
#12 0x00005598918d8cb5 clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x40a4cb5)
#13 0x00005598918da37d clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x40a637d)
#14 0x0000559891b47ab5 clang::CodeGen::CodeGenFunction::EmitAutoVarAlloca(clang::VarDecl const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4313ab5)
#15 0x0000559891b48023 clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (.part.0) CGDecl.cpp:0:0
#16 0x0000559891b48320 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4314320)
#17 0x00005598917a3397 clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f6f397)
#18 0x00005598917b7a1f clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f83a1f)
#19 0x00005598917b0969 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f7c969)
#20 0x00005598917b72d4 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f832d4)
#21 0x000055989181726a clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fe326a)
#22 0x000055989182ae9f clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ff6e9f)
#23 0x000055989188fe09 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x405be09)
#24 0x000055989188adb5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4056db5)
#25 0x000055989188b988 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4057988)
#26 0x00005598918947d3 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#27 0x0000559892703ac6 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#28 0x00005598926f5b70 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4ec1b70)
#29 0x0000559893bfde14 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x63c9e14)
#30 0x00005598927009a8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4ecc9a8)
#31 0x0000559891f4ab79 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4716b79)
#32 0x0000559891ed04c6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x469c4c6)
#33 0x000055989202f2a6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x47fb2a6)
#34 0x000055988e9290ed cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x10f50ed)
#35 0x000055988e924dea ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#36 0x0000559891d2f23d 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
#37 0x00005598913cf8a0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b9b8a0)
#38 0x0000559891d2f85f 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
#39 0x0000559891cf69ec clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44c29ec)
#40 0x0000559891cf747d 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+0x44c347d)
#41 0x0000559891cff55d clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44cb55d)
#42 0x000055988e92734a clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x10f334a)
#43 0x000055988e82d5c5 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xff95c5)
#44 0x00007fb1fab09083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#45 0x000055988e91fbce _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x10ebbce)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134

wierton avatar Jun 28 '23 02:06 wierton

@llvm/issue-subscribers-clang-codegen

llvmbot avatar Jun 28 '23 02:06 llvmbot

Are these organic bugs or are you using a fuzzing or automation tool to generate these bugs?

We don't have the bandwidth for mass submission of fuzzer generated bugs but carefully curated fuzzer generated bugs submissions are definitely welcome.

shafik avatar Jun 28 '23 04:06 shafik

Are these organic bugs or are you using a fuzzing or automation tool to generate these bugs?

We don't have the bandwidth for mass submission of fuzzer generated bugs but carefully curated fuzzer generated bugs submissions are definitely welcome.

These are test cases generated by our unpublished fuzzing tools. Before submitting, I have already performed automatic deduplication and conducted manual reduction and manual checks to ensure that the submitted test cases are simplified and have no duplicates. If there are any inadvertent duplicates, I would be more than happy to improve my deduplication tool and try to avoid such situations during manual checks. In addition, if there is a strict submission format for errors detected by fuzz testing tools, such as indicating it in the title, I am willing to submit according to the format you require. Is there a reference format that I should follow?

wierton avatar Jun 28 '23 04:06 wierton

May be a duplicate of: https://github.com/llvm/llvm-project/issues/36427

shafik avatar Jul 17 '23 16:07 shafik