llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.79k stars 11.9k forks source link

Crash after explicit call to a base constructor with virtual base #42101

Open llvmbot opened 5 years ago

llvmbot commented 5 years ago
Bugzilla Link 42756
Version 8.0
OS Windows NT
Attachments Minimal example that reproduces the issue
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@zygoloid

Extended Description

The code below crashes Windows:

struct interface { }; struct base1_if : virtual interface { }; struct base2_if : virtual interface { }; struct base_if : base1_if, base2_if { };

struct derived : base_if { derived() : base_if() { } };

int main() { derived d; }

Command line: $ clang-cl -v clang version 8.0.0 (tags/RELEASE_800/final) Target: x86_64-pc-windows-msvc Thread model: posix InstalledDir: C:\Program Files\LLVM\bin $ clang-cl main.cpp $ main.exe

Few notes:

llvmbot commented 5 years ago

Typo fix: assembly contains "memset(addr, 0, 0FFFFFFFFFFFFFFF8h)".

Endilll commented 1 year ago

Still crashing as of post-17 trunk: https://godbolt.org/z/EEdETnMsK

clang++: /root/llvm-project/clang/lib/CodeGen/CGExprCXX.cpp:536:
void EmitNullBaseClassInitialization(clang::CodeGen::CodeGenFunction&, clang::CodeGen::Address, const clang::CXXRecordDecl*):
Assertion `!SplitAfterSize.isNegative() && "negative store size!"' 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 -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -target x86_64-pc-windows-msvc <source>
1.  <eof> parser at end of file
2.  Per-file LLVM IR generation
3.  <source>:7:5: Generating code for declaration 'derived::derived'
 #0 0x00000000036bb0e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36bb0e8)
 #1 0x00000000036b8dac llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36b8dac)
 #2 0x00000000036021c8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007fc7974f6420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007fc796fb900b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007fc796f98859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00007fc796f98729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #7 0x00007fc796fa9fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #8 0x0000000003de6928 clang::CodeGen::CodeGenFunction::EmitCXXConstructExpr(clang::CXXConstructExpr const*, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3de6928)
 #9 0x0000000003dc9ef7 (anonymous namespace)::AggExprEmitter::VisitCXXConstructExpr(clang::CXXConstructExpr const*) CGExprAgg.cpp:0:0
#10 0x0000000003dcf49b (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) CGExprAgg.cpp:0:0
#11 0x0000000003dd15bb clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3dd15bb)
#12 0x0000000003d58ace EmitBaseInitializer(clang::CodeGen::CodeGenFunction&, clang::CXXRecordDecl const*, clang::CXXCtorInitializer*) (.part.0) CGClass.cpp:0:0
#13 0x0000000003d58d8c clang::CodeGen::CodeGenFunction::EmitCtorPrologue(clang::CXXConstructorDecl const*, clang::CXXCtorType, clang::CodeGen::FunctionArgList&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d58d8c)
#14 0x0000000003d5b43b clang::CodeGen::CodeGenFunction::EmitConstructorBody(clang::CodeGen::FunctionArgList&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d5b43b)
#15 0x0000000003a4d68d clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a4d68d)
#16 0x0000000003d1a9c5 clang::CodeGen::CodeGenModule::codegenCXXStructor(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d1a9c5)
#17 0x0000000003b2d6d1 (anonymous namespace)::MicrosoftCXXABI::emitCXXStructor(clang::GlobalDecl) MicrosoftCXXABI.cpp:0:0
#18 0x0000000003aa96b5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3aa96b5)
#19 0x0000000003ab4746 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ab4746)
#20 0x0000000003ab7213 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ab7213)
#21 0x000000000491f16a (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#22 0x000000000491db35 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x491db35)
#23 0x0000000005e13cf9 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5e13cf9)
#24 0x000000000491c718 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x491c718)
#25 0x000000000417a659 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x417a659)
#26 0x00000000040fcfae clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40fcfae)
#27 0x000000000425ab76 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x425ab76)
#28 0x0000000000bd3e2e cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbd3e2e)
#29 0x0000000000bcc4ea ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#30 0x0000000003f5de29 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
#31 0x0000000003602674 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3602674)
#32 0x0000000003f5e41f 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
#33 0x0000000003f267a5 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f267a5)
#34 0x0000000003f2720d 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+++0x3f2720d)
#35 0x0000000003f2f135 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f2f135)
#36 0x0000000000bd20cc clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbd20cc)
#37 0x0000000000ace021 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xace021)
#38 0x00007fc796f9a083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#39 0x0000000000bcbfce _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbcbfce)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-codegen