Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Clang crash with: Assertion failed: (dominatingIP && "no existing variable and no dominating IP!"), function SetupCleanupBlockActivation #38703

Open Quuxplusone opened 5 years ago

Quuxplusone commented 5 years ago
Bugzilla Link PR39732
Status NEW
Importance P normal
Reported by Max Langhof (max.langhof@gmx.de)
Reported on 2018-11-20 12:44:24 -0800
Last modified on 2019-11-29 10:36:01 -0800
Version trunk
Hardware PC All
CC florian_hahn@apple.com, htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also PR40092
Minimal code (https://godbolt.org/z/R6TQQ8):

  #include <memory>

  struct A {
    std::unique_ptr<int> x;
  };

  struct B {
    std::unique_ptr<int> y;
  };

  struct AB : A, B
  {};

  void foo() {
    AB ab{ nullptr, std::make_unique<int>(1) };
  }

Condensed, most interesting cases:
https://godbolt.org/z/R1WNy3

Lots of test cases:
https://godbolt.org/z/dTpb4-

This crash exists in all clang versions (that are new enough to compile the
above), see godbolt links.

##############

Stack trace:

0.  Program arguments: /opt/compiler-explorer/clang-trunk-20181111/bin/clang-8 -
cc1 -triple x86_64-unknown-linux-gnu -S -disable-free -disable-llvm-verifier -
discard-value-names -main-file-name example.cpp -mrelocation-model static -
mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-
tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debug-info-
kind=limited -dwarf-version=4 -debugger-tuning=gdb -momit-leaf-frame-pointer -
coverage-notes-file /tmp/compiler-explorer-compiler1181020-55-
j6o6z1.avoz/output.gcno -resource-dir /opt/compiler-explorer/clang-trunk-
20181111/lib/clang/8.0.0 -internal-isystem /opt/compiler-explorer/gcc-
8.2.0/lib/gcc/x86_64-linux-gnu/8.2.0/../../../../include/c++/8.2.0 -internal-
isystem /opt/compiler-explorer/gcc-8.2.0/lib/gcc/x86_64-linux-
gnu/8.2.0/../../../../include/c++/8.2.0/x86_64-linux-gnu -internal-isystem
/opt/compiler-explorer/gcc-8.2.0/lib/gcc/x86_64-linux-
gnu/8.2.0/../../../../include/c++/8.2.0/backward -internal-isystem
/usr/local/include -internal-isystem /opt/compiler-explorer/clang-trunk-
20181111/lib/clang/8.0.0/include -internal-externc-isystem /usr/include/x86_64-
linux-gnu -internal-externc-isystem /include -internal-externc-isystem
/usr/include -O1 -std=c++17 -fdeprecated-macro -fdebug-compilation-dir
/tmp/compiler-explorer-compiler1181020-55-j6o6z1.avoz -ferror-limit 19 -
fmessage-length 0 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -
fdiagnostics-show-option -fcolor-diagnostics -mllvm --x86-asm-syntax=intel -o
/tmp/compiler-explorer-compiler1181020-55-j6o6z1.avoz/output.s -x c++ <source> -
faddrsig

1.  <eof> parser at end of file

2.  Per-function optimization

3.  Running pass 'SROA' on function '@_Z3foov'

#0 0x000055f18ccfdcfa llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/opt/compiler-explorer/clang-trunk-20181111/bin/clang-8+0x2362cfa)

#1 0x000055f18ccfc264 llvm::sys::RunSignalHandlers() (/opt/compiler-
explorer/clang-trunk-20181111/bin/clang-8+0x2361264)

#2 0x000055f18ccfc3a2 SignalHandler(int) (/opt/compiler-explorer/clang-trunk-
20181111/bin/clang-8+0x23613a2)

#3 0x00007effde8ed890 __restore_rt (/lib/x86_64-linux-
gnu/libpthread.so.0+0x12890)

#4 0x000055f18c69f8f0 llvm::BasicBlock::getModule() const (/opt/compiler-
explorer/clang-trunk-20181111/bin/clang-8+0x1d048f0)

#5 0x000055f18cc0fd0e
llvm::sroa::AllocaSlices::SliceBuilder::visitStoreInst(llvm::StoreInst&)
(/opt/compiler-explorer/clang-trunk-20181111/bin/clang-8+0x2274d0e)

#6 0x000055f18cc15753 llvm::sroa::AllocaSlices::AllocaSlices(llvm::DataLayout
const&, llvm::AllocaInst&) (/opt/compiler-explorer/clang-trunk-
20181111/bin/clang-8+0x227a753)

#7 0x000055f18cc204db llvm::SROA::runOnAlloca(llvm::AllocaInst&) (/opt/compiler-
explorer/clang-trunk-20181111/bin/clang-8+0x22854db)

#8 0x000055f18cc22231 llvm::SROA::runImpl(llvm::Function&,
llvm::DominatorTree&, llvm::AssumptionCache&) (/opt/compiler-explorer/clang-
trunk-20181111/bin/clang-8+0x2287231)

#9 0x000055f18cc23dbc
llvm::sroa::SROALegacyPass::runOnFunction(llvm::Function&) (/opt/compiler-
explorer/clang-trunk-20181111/bin/clang-8+0x2288dbc)

#10 0x000055f18c74aa09 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/opt/compiler-explorer/clang-trunk-20181111/bin/clang-8+0x1dafa09)

#11 0x000055f18c74ab1c
llvm::legacy::FunctionPassManagerImpl::run(llvm::Function&) (/opt/compiler-
explorer/clang-trunk-20181111/bin/clang-8+0x1dafb1c)

#12 0x000055f18c74ae02 llvm::legacy::FunctionPassManager::run(llvm::Function&)
(/opt/compiler-explorer/clang-trunk-20181111/bin/clang-8+0x1dafe02)

#13 0x000055f18cf0356b (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >) (/opt/compiler-explorer/clang-
trunk-20181111/bin/clang-8+0x256856b)

#14 0x000055f18cf05cfe clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >) (/opt/compiler-explorer/clang-
trunk-20181111/bin/clang-8+0x256acfe)

#15 0x000055f18d821eaf
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/opt/compiler-explorer/clang-trunk-20181111/bin/clang-8+0x2e86eaf)

#16 0x000055f18df9b2b9 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-
explorer/clang-trunk-20181111/bin/clang-8+0x36002b9)

#17 0x000055f18d820da7 clang::CodeGenAction::ExecuteAction() (/opt/compiler-
explorer/clang-trunk-20181111/bin/clang-8+0x2e85da7)

#18 0x000055f18d3810c6 clang::FrontendAction::Execute() (/opt/compiler-
explorer/clang-trunk-20181111/bin/clang-8+0x29e60c6)

#19 0x000055f18d345a2c
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-
explorer/clang-trunk-20181111/bin/clang-8+0x29aaa2c)

#20 0x000055f18d43d76b
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-
explorer/clang-trunk-20181111/bin/clang-8+0x2aa276b)

#21 0x000055f18b441668 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk-20181111/bin/clang-8+0xaa6668)

#22 0x000055f18b395b09 main (/opt/compiler-explorer/clang-trunk-
20181111/bin/clang-8+0x9fab09)

#23 0x00007effdd7a6b97 __libc_start_main (/lib/x86_64-linux-
gnu/libc.so.6+0x21b97)

#24 0x000055f18b43e90a _start (/opt/compiler-explorer/clang-trunk-
20181111/bin/clang-8+0xaa390a)
Quuxplusone commented 5 years ago

Last godbolt link is not correctly parsed for automatic link generation, this one works: https://godbolt.org/z/9yA5Nq

Quuxplusone commented 5 years ago
With assertions, this actually crashed in clang:

Assertion failed: (dominatingIP && "no existing variable and no dominating
IP!"), function SetupCleanupBlockActivation, file llvm-
project/clang/lib/CodeGen/CGCleanup.cpp, line 1214.

Updating title and move to clang
Quuxplusone commented 4 years ago
Good news: This bug, as well as the linked bug 40092, can no longer be
reproduced on any optimization level with the given code samples under clang
9.0 or clang trunk.

godbolt links for convenience:

https://godbolt.org/z/k5Q7q4 (minimal, pass)
https://godbolt.org/z/kPB_Hb (all tests, pass)

https://godbolt.org/z/BuX7R4 (bug 40092, pass)

I have not identified which exact change caused this (apparent) fix.