[llvm-bugs] [Bug 38024] New: clang crashes at -O1 and above on x86_64-linux-gnu: Assertion `RHS.U.VAL != 0 && "Divide by zero?"' failed.

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 2 14:58:02 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=38024

            Bug ID: 38024
           Summary: clang crashes at -O1 and above on x86_64-linux-gnu:
                    Assertion `RHS.U.VAL != 0 && "Divide by zero?"'
                    failed.
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: helloqirun at gmail.com
                CC: llvm-bugs at lists.llvm.org

$ clang-trunk -v
clang version 7.0.0 (trunk 336083)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin



$ clang-trunk -O1 abc.c
clang-7: /home/absozero/trunk/llvm/lib/Support/APInt.cpp:1535: llvm::APInt
llvm::APInt::udiv(const llvm::APInt &) const: Assertion `RHS.U.VAL != 0 &&
"Divide by zero?"' failed.
Stack dump:
0.      Program arguments: /home/absozero/trunk/root-clang/bin/clang-7 -cc1
-triple x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name abc.c
-mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -resource-dir
/home/absozero/trunk/root-clang/lib/clang/7.0.0 -internal-isystem
/usr/local/include -internal-isystem
/home/absozero/trunk/root-clang/lib/clang/7.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O1
-fdebug-compilation-dir /home/absozero/projects/reduction/crash -ferror-limit
19 -fmessage-length 142 -fobjc-runtime=gcc -fdiagnostics-show-option
-fcolor-diagnostics -o /tmp/abc-2e891d.o -x c abc.c 
1.      <eof> parser at end of file
2.      Per-module optimization passes
3.      Running pass 'CallGraph Pass Manager' on module 'abc.c'.
4.      Running pass 'Loop Pass Manager' on function '@fn1'
5.      Running pass 'Induction Variable Simplification' on basic block
'%for.cond'
#0 0x00000000020c3c94 PrintStackTraceSignalHandler(void*)
(/home/absozero/trunk/root-clang/bin/clang-7+0x20c3c94)
#1 0x00000000020c1bee llvm::sys::RunSignalHandlers()
(/home/absozero/trunk/root-clang/bin/clang-7+0x20c1bee)
#2 0x00000000020c3e52 SignalHandler(int)
(/home/absozero/trunk/root-clang/bin/clang-7+0x20c3e52)
#3 0x00007fc8b4fb7330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#4 0x00007fc8b3b92c37 gsignal
/build/eglibc-ripdx6/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007fc8b3b96028 abort
/build/eglibc-ripdx6/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007fc8b3b8bbf6 __assert_fail_base
/build/eglibc-ripdx6/eglibc-2.19/assert/assert.c:92:0
#7 0x00007fc8b3b8bca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#8 0x0000000002053d23 llvm::APInt::udiv(llvm::APInt const&) const
(/home/absozero/trunk/root-clang/bin/clang-7+0x2053d23)
#9 0x0000000002059c74 llvm::APInt::sdiv(llvm::APInt const&) const
(/home/absozero/trunk/root-clang/bin/clang-7+0x2059c74)
#10 0x00000000016daae6 SolveQuadraticEquation(llvm::SCEVAddRecExpr const*,
llvm::ScalarEvolution&) (/home/absozero/trunk/root-clang/bin/clang-7+0x16daae6)
#11 0x00000000016d55bb llvm::ScalarEvolution::howFarToZero(llvm::SCEV const*,
llvm::Loop const*, bool, bool)
(/home/absozero/trunk/root-clang/bin/clang-7+0x16d55bb)
#12 0x00000000016d1c47
llvm::ScalarEvolution::computeExitLimitFromICmp(llvm::Loop const*,
llvm::ICmpInst*, bool, bool, bool)
(/home/absozero/trunk/root-clang/bin/clang-7+0x16d1c47)
#13 0x00000000016d1303
llvm::ScalarEvolution::computeExitLimitFromCondImpl(llvm::ScalarEvolution::ExitLimitCache&,
llvm::Loop const*, llvm::Value*, bool, bool, bool)
(/home/absozero/trunk/root-clang/bin/clang-7+0x16d1303)
#14 0x00000000016d0e68
llvm::ScalarEvolution::computeExitLimitFromCondCached(llvm::ScalarEvolution::ExitLimitCache&,
llvm::Loop const*, llvm::Value*, bool, bool, bool)
(/home/absozero/trunk/root-clang/bin/clang-7+0x16d0e68)
#15 0x00000000016d06b5 llvm::ScalarEvolution::computeExitLimit(llvm::Loop
const*, llvm::BasicBlock*, bool)
(/home/absozero/trunk/root-clang/bin/clang-7+0x16d06b5)
#16 0x00000000016ce3cf
llvm::ScalarEvolution::computeBackedgeTakenCount(llvm::Loop const*, bool)
(/home/absozero/trunk/root-clang/bin/clang-7+0x16ce3cf)
#17 0x00000000016cd18d llvm::ScalarEvolution::getBackedgeTakenInfo(llvm::Loop
const*) (/home/absozero/trunk/root-clang/bin/clang-7+0x16cd18d)
#18 0x00000000016cdf8f llvm::ScalarEvolution::getBackedgeTakenCount(llvm::Loop
const*) (/home/absozero/trunk/root-clang/bin/clang-7+0x16cdf8f)
#19 0x0000000001ec03e0 (anonymous namespace)::IndVarSimplify::run(llvm::Loop*)
(/home/absozero/trunk/root-clang/bin/clang-7+0x1ec03e0)
#20 0x0000000001ecbc4d (anonymous
namespace)::IndVarSimplifyLegacyPass::runOnLoop(llvm::Loop*,
llvm::LPPassManager&) (/home/absozero/trunk/root-clang/bin/clang-7+0x1ecbc4d)
#21 0x000000000166cb8a llvm::LPPassManager::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x166cb8a)
#22 0x0000000001b88ca6 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x1b88ca6)
#23 0x00000000015bcf3c (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x15bcf3c)
#24 0x0000000001b894d0 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x1b894d0)
#25 0x0000000002290989 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> >)
(/home/absozero/trunk/root-clang/bin/clang-7+0x2290989)
#26 0x0000000002bc0cd0
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x2bc0cd0)
#27 0x000000000315b794 clang::ParseAST(clang::Sema&, bool, bool)
(/home/absozero/trunk/root-clang/bin/clang-7+0x315b794)
#28 0x0000000002735cf0 clang::FrontendAction::Execute()
(/home/absozero/trunk/root-clang/bin/clang-7+0x2735cf0)
#29 0x00000000026dee11
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x26dee11)
#30 0x00000000027da7a9
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/absozero/trunk/root-clang/bin/clang-7+0x27da7a9)
#31 0x000000000091ccc8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/absozero/trunk/root-clang/bin/clang-7+0x91ccc8)
#32 0x000000000091a60f main
(/home/absozero/trunk/root-clang/bin/clang-7+0x91a60f)
#33 0x00007fc8b3b7df45 __libc_start_main
/build/eglibc-ripdx6/eglibc-2.19/csu/libc-start.c:321:0
#34 0x000000000091769d _start
(/home/absozero/trunk/root-clang/bin/clang-7+0x91769d)
clang-7: error: unable to execute command: Aborted (core dumped)
clang-7: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 7.0.0 (trunk 336083)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-7: 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-7: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-7: note: diagnostic msg: /tmp/abc-836170.c
clang-7: note: diagnostic msg: /tmp/abc-836170.sh
clang-7: note: diagnostic msg: 

********************



$ cat abc.c
short a;
int *b;
int c;
void fn1() {
  a = 0;
  b = &c;
  *b = 3;
  for (;; *b += 1)
    if ((9 || 0) & (a += c) ? 0 : 4)
      for (;;)
        ;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180702/fd75dbb7/attachment.html>


More information about the llvm-bugs mailing list