Open llvmbot opened 4 years ago
This is actually an assertion:
Assertion failed: (!elementType->isArrayType()), function emitArrayDestroy, file clang/lib/CodeGen/CGDecl.cpp, line 2149.
If needed, here is the dump from clang :
test.cpp:13:3: warning: deleting pointer to incomplete type 'A []' may cause undefined behavior [-Wdelete-incomplete] delete[] b; ^ ~ Stack dump:
clang: error: unable to execute command: Segmentation fault (core dumped) clang: error: clang frontend command failed due to signal (use -v to see invocation) clang version 10.0.0-4ubuntu1 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin clang: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script. clang: note: diagnostic msg:
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang: note: diagnostic msg: /tmp/test-fa1306.cpp clang: note: diagnostic msg: /tmp/test-fa1306.sh clang: note: diagnostic msg:
Still crashing as of post-17 trunk: https://godbolt.org/z/hdWGc9qqb
<source>:12:3: warning: deleting pointer to incomplete type 'A[]' may cause undefined behavior [-Wdelete-incomplete]
12 | delete[] b;
| ^ ~
clang++: /root/llvm-project/clang/lib/CodeGen/CGDecl.cpp:2294:
void clang::CodeGen::CodeGenFunction::emitArrayDestroy(llvm::Value*, llvm::Value*, clang::QualType, clang::CharUnits, void (*)(clang::CodeGen::CodeGenFunction&, clang::CodeGen::Address, clang::QualType), bool, bool):
Assertion `!elementType->isArrayType()' 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 <source>
1. <eof> parser at end of file
2. <source>:6:5: LLVM IR generation of declaration 'main'
3. <source>:6:5: Generating code for declaration 'main'
#0 0x0000000003673848 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3673848)
#1 0x00000000036716cc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36716cc)
#2 0x00000000035bef28 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007fab25329420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007fab24dec00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007fab24dcb859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007fab24dcb729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007fab24ddcfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x0000000003d2e00c clang::CodeGen::CodeGenFunction::emitArrayDestroy(llvm::Value*, llvm::Value*, clang::QualType, clang::CharUnits, void (*)(clang::CodeGen::CodeGenFunction&, clang::CodeGen::Address, clang::QualType), bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d2e00c)
#9 0x0000000003d9b566 clang::CodeGen::CodeGenFunction::EmitCXXDeleteExpr(clang::CXXDeleteExpr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d9b566)
#10 0x0000000003dbabde clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#11 0x0000000003dc26dc clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3dc26dc)
#12 0x0000000003d58c76 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d58c76)
#13 0x0000000003d79c2b clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d79c2b)
#14 0x0000000003989432 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3989432)
#15 0x000000000398f8ac clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x398f8ac)
#16 0x00000000039ed076 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x39ed076)
#17 0x0000000003a0016a clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a0016a)
#18 0x0000000003a614cd clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a614cd)
#19 0x0000000003a5c685 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a5c685)
#20 0x0000000003a5cc43 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a5cc43)
#21 0x0000000003a65e13 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#22 0x00000000048c8726 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#23 0x00000000048baec8 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48baec8)
#24 0x0000000005d80464 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5d80464)
#25 0x00000000048c5798 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48c5798)
#26 0x000000000412d9d9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x412d9d9)
#27 0x00000000040b1d6e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40b1d6e)
#28 0x000000000420dc46 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x420dc46)
#29 0x0000000000bcb672 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbcb672)
#30 0x0000000000bc3e5a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#31 0x0000000003f11c19 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
#32 0x00000000035bf3d4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x35bf3d4)
#33 0x0000000003f1220f 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
#34 0x0000000003eda175 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3eda175)
#35 0x0000000003edabdd 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+++0x3edabdd)
#36 0x0000000003ee2705 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ee2705)
#37 0x0000000000bc9927 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbc9927)
#38 0x0000000000ac39f1 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xac39f1)
#39 0x00007fab24dcd083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#40 0x0000000000bc393e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbc393e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
@llvm/issue-subscribers-clang-codegen
Extended Description
Hi,
When using 2D array with clang, I found a way to cause a segmentation fault of the clang compiler (checked 10 on my WSL) and on the trunk version with godbolt.
The minimal example is the following :
This code compiles without warning nor errors with MSVC 19.24 and gcc 7.5. I do not mind the error or warning from clang, but the seg fault that follows is an issue.
Attached is the cpp and sh generated by clang on crash.
Best,
Karol