llvm / llvm-project

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

SafeStackColoring assertion failed in calculateLiveIntervals(): `!Started.test(AllocaNo)' #29666

Closed llvmbot closed 8 years ago

llvmbot commented 8 years ago
Bugzilla Link 30318
Resolution FIXED
Resolved on Sep 16, 2016 17:14
Version trunk
OS Linux
Attachments Preprocessed source file., The run script.
Reporter LLVM Bugzilla Contributor
CC @eugenis,@vitalybuka

Extended Description

I was attempting to build Python v.3.5.2 with SafeStack enabled when the following assertion failure occurred. I have attached the preprocessed source and the run script. Here is the backtrace:

clang-4.0: /home/mlemay/llvm/llvm/lib/CodeGen/SafeStackColoring.cpp:217: void llvm::safestack::StackColoring::calculateLiveIntervals(): Assertion `!Started.test(AllocaNo)' failed.

​0 0x00000000024fe259 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/mlemay/llvm/inst/bin/clang-4.0+0x24fe259)

​1 0x00000000024fe5f8 PrintStackTraceSignalHandler(void*) (/home/mlemay/llvm/inst/bin/clang-4.0+0x24fe5f8)

​2 0x00000000024fc5be llvm::sys::RunSignalHandlers() (/home/mlemay/llvm/inst/bin/clang-4.0+0x24fc5be)

​3 0x00000000024fd9e4 SignalHandler(int) (/home/mlemay/llvm/inst/bin/clang-4.0+0x24fd9e4)

​4 0x00007ff151b793d0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x113d0)

​5 0x00007ff1508e6418 gsignal /build/glibc-GKVZIf/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0

​6 0x00007ff1508e801a abort /build/glibc-GKVZIf/glibc-2.23/stdlib/abort.c:91:0

​7 0x00007ff1508debd7 __assert_fail_base /build/glibc-GKVZIf/glibc-2.23/assert/assert.c:92:0

​8 0x00007ff1508dec82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)

​9 0x0000000001badb64 llvm::safestack::StackColoring::calculateLiveIntervals() (/home/mlemay/llvm/inst/bin/clang-4.0+0x1badb64)

​10 0x0000000001bae885 llvm::safestack::StackColoring::run() (/home/mlemay/llvm/inst/bin/clang-4.0+0x1bae885)

​11 0x0000000001ba4aac (anonymous namespace)::SafeStack::moveStaticAllocasToUnsafeStack(llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&, llvm::Function&, llvm::ArrayRef<llvm::AllocaInst>, llvm::ArrayRef<llvm::Argument>, llvm::ArrayRef<llvm::ReturnInst>, llvm::Instruction, llvm::AllocaInst*) (/home/mlemay/llvm/inst/bin/clang-4.0+0x1ba4aac)

​12 0x0000000001ba69e2 (anonymous namespace)::SafeStack::runOnFunction(llvm::Function&) (/home/mlemay/llvm/inst/bin/clang-4.0+0x1ba69e2)

​13 0x0000000001f8c590 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/mlemay/llvm/inst/bin/clang-4.0+0x1f8c590)

​14 0x0000000001f8c729 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/mlemay/llvm/inst/bin/clang-4.0+0x1f8c729)

​15 0x0000000001f8caa4 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) (/home/mlemay/llvm/inst/bin/clang-4.0+0x1f8caa4)

​16 0x0000000001f8d1d5 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/mlemay/llvm/inst/bin/clang-4.0+0x1f8d1d5)

​17 0x0000000001f8d3e1 llvm::legacy::PassManager::run(llvm::Module&) (/home/mlemay/llvm/inst/bin/clang-4.0+0x1f8d3e1)

​18 0x000000000279d1d9 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete >) (/home/mlemay/llvm/inst/bin/clang-4.0+0x279d1d9)

​19 0x000000000279df21 clang::EmitBackendOutput(clang::DiagnosticsEngine&, 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 >) (/home/mlemay/llvm/inst/bin/clang-4.0+0x279df21)

​20 0x0000000003185d65 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/mlemay/llvm/inst/bin/clang-4.0+0x3185d65)

​21 0x0000000003cdbc81 clang::ParseAST(clang::Sema&, bool, bool) (/home/mlemay/llvm/inst/bin/clang-4.0+0x3cdbc81)

​22 0x0000000002d2af21 clang::ASTFrontendAction::ExecuteAction() (/home/mlemay/llvm/inst/bin/clang-4.0+0x2d2af21)

​23 0x000000000318908a clang::CodeGenAction::ExecuteAction() (/home/mlemay/llvm/inst/bin/clang-4.0+0x318908a)

​24 0x0000000002d2a98e clang::FrontendAction::Execute() (/home/mlemay/llvm/inst/bin/clang-4.0+0x2d2a98e)

​25 0x0000000002cd9b45 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/mlemay/llvm/inst/bin/clang-4.0+0x2cd9b45)

​26 0x0000000002e58b7e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/mlemay/llvm/inst/bin/clang-4.0+0x2e58b7e)

​27 0x00000000015a41e2 cc1_main(llvm::ArrayRef<char const>, char const, void*) (/home/mlemay/llvm/inst/bin/clang-4.0+0x15a41e2)

​28 0x000000000159a64e ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef) (/home/mlemay/llvm/inst/bin/clang-4.0+0x159a64e)

​29 0x000000000159b2d9 main (/home/mlemay/llvm/inst/bin/clang-4.0+0x159b2d9)

​30 0x00007ff1508d1830 __libc_start_main /build/glibc-GKVZIf/glibc-2.23/csu/../csu/libc-start.c:325:0

​31 0x0000000001596609 _start (/home/mlemay/llvm/inst/bin/clang-4.0+0x1596609)

Stack dump:

  1. Program arguments: /home/mlemay/llvm/inst/bin/clang-4.0 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name ceval.c -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -momit-leaf-frame-pointer -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -coverage-notes-file /home/mlemay/safestack/python3.5/Python-3.5.2/Python/ceval.gcno -resource-dir /home/mlemay/llvm/inst/bin/../lib/clang/4.0.0 -D NDEBUG -I . -I Include -I ./Include -D Py_BUILD_CORE -internal-isystem /usr/local/include -internal-isystem /home/mlemay/llvm/inst/bin/../lib/clang/4.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wno-unused-result -Wsign-compare -Wunreachable-code -Wall -Wstrict-prototypes -Werror=declaration-after-statement -fdebug-compilation-dir /home/mlemay/safestack/python3.5/Python-3.5.2 -ferror-limit 19 -fmessage-length 212 -fsanitize=safe-stack -fwrapv -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o Python/ceval.o -x c Python/ceval.c
  2. parser at end of file
  3. Code generation
  4. Running pass 'Function Pass Manager' on module 'Python/ceval.c'.
  5. Running pass 'Safe Stack instrumentation pass' on function '@PyEval_EvalFrameEx' clang-4.0: error: unable to execute command: Aborted (core dumped) clang-4.0: error: clang frontend command failed due to signal (use -v to see invocation) clang version 4.0.0 (http://llvm.org/git/clang.git 7e8dc8a5df27b2ef6bbbffcbd974ea94f5cc8a6c) (http://llvm.org/git/llvm.git 5cf52dab7bfc175b98e16d113dc1d2c9126154c1) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/mlemay/llvm/inst/bin
eugenis commented 8 years ago

Fixed in https://reviews.llvm.org/rL281784

This is what it reduced to:

define i8 @​zot() safestack { bb: %tmp = alloca i8, align 8 %tmp2 = bitcast i8* %tmp to i8 br label %bb3

bb3: ; preds = %bb3, %bb call void @​llvm.lifetime.start(i64 8, i8* nonnull %tmp2) %tmp4 = call i32 @​wombat(i8* nonnull %tmp) indirectbr i8 undef, [label %bb3] }

declare i32 @​wombat(i8**)

eugenis commented 8 years ago

non-minimized bitcode reproducer opt -safe-stack 2.ll # attached