[llvm-bugs] [Bug 24723] New: clang crashes on valid code at -O2 and -O3 on x86_64-linux-gnu

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Sep 5 14:02:16 PDT 2015


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

            Bug ID: 24723
           Summary: clang crashes on valid code at -O2 and -O3 on
                    x86_64-linux-gnu
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The current clang trunk (and 3.7.0) crashes when compiling the following test
case at -O2 and -O3 on x86_64-linux-gnu in both 32-bit and 64-bit modes. 

This is a regression from 3.6.x. 


$ clang-trunk -v
clang version 3.8.0 (trunk 246931)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/tools/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.2
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.1.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.1.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$
$ clang-trunk -Os -c small.c
$ clang-3.6 -O2 -c small.c
$
$ clang-trunk -O2 -c small.c
clang: /tmp/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp:103: void
llvm::BlockFrequencyInfoImplBase::Distribution::add(const
llvm::BlockFrequencyInfoImplBase::BlockNode&, uint64_t,
llvm::BlockFrequencyInfoImplBase::Weight::DistType): Assertion `Amount &&
"invalid weight of 0"' failed.
#0 0x2efb458 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang+0x2efb458)
#1 0x2efa246 llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang+0x2efa246)
#2 0x2efa456 (/usr/local/clang-trunk/bin/clang+0x2efa456)
#3 0x7f3412ce6340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x7f3411c81cc9 gsignal
/build/buildd/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x7f3411c850d8 abort /build/buildd/eglibc-2.19/stdlib/abort.c:91:0
#6 0x7f3411c7ab86 __assert_fail_base
/build/buildd/eglibc-2.19/assert/assert.c:92:0
#7 0x7f3411c7ac32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x2b08718
llvm::BlockFrequencyInfoImplBase::Distribution::add(llvm::BlockFrequencyInfoImplBase::BlockNode
const&, unsigned long, llvm::BlockFrequencyInfoImplBase::Weight::DistType)
(/usr/local/clang-trunk/bin/clang+0x2b08718)
#9 0x2b0c278
llvm::BlockFrequencyInfoImplBase::adjustLoopHeaderMass(llvm::BlockFrequencyInfoImplBase::LoopData&)
(/usr/local/clang-trunk/bin/clang+0x2b0c278)
#10 0x269134a
llvm::BlockFrequencyInfoImpl<llvm::MachineBasicBlock>::computeMassInLoop(llvm::BlockFrequencyInfoImplBase::LoopData&)
(/usr/local/clang-trunk/bin/clang+0x269134a)
#11 0x26949d4
llvm::BlockFrequencyInfoImpl<llvm::MachineBasicBlock>::computeIrreducibleMass(llvm::BlockFrequencyInfoImplBase::LoopData*,
std::_List_iterator<llvm::BlockFrequencyInfoImplBase::LoopData>)
(/usr/local/clang-trunk/bin/clang+0x26949d4)
#12 0x2694f1e
llvm::BlockFrequencyInfoImpl<llvm::MachineBasicBlock>::calculate(llvm::MachineFunction
const&, llvm::MachineBranchProbabilityInfo const&, llvm::MachineLoopInfo
const&) (/usr/local/clang-trunk/bin/clang+0x2694f1e)
#13 0x2696431
llvm::MachineBlockFrequencyInfo::runOnMachineFunction(llvm::MachineFunction&)
(/usr/local/clang-trunk/bin/clang+0x2696431)
#14 0x2e6b0ff llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang+0x2e6b0ff)
#15 0x2e6b13b llvm::FPPassManager::runOnModule(llvm::Module&)
(/usr/local/clang-trunk/bin/clang+0x2e6b13b)
#16 0x2e6c8b7 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang+0x2e6c8b7)
#17 0xb68328 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions
const&, llvm::StringRef, llvm::Module*, clang::BackendAction,
llvm::raw_pwrite_stream*) (/usr/local/clang-trunk/bin/clang+0xb68328)
#18 0xb52366 (/usr/local/clang-trunk/bin/clang+0xb52366)
#19 0xd8ad82 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang+0xd8ad82)
#20 0xb54b52 clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang+0xb54b52)
#21 0x954cc6 clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang+0x954cc6)
#22 0x928cbe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang+0x928cbe)
#23 0x90cf0c clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang+0x90cf0c)
#24 0x904af0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
(/usr/local/clang-trunk/bin/clang+0x904af0)
#25 0x8eadda main (/usr/local/clang-trunk/bin/clang+0x8eadda)
#26 0x7f3411c6cec5 __libc_start_main
/build/buildd/eglibc-2.19/csu/libc-start.c:321:0
#27 0x90316d _start (/usr/local/clang-trunk/bin/clang+0x90316d)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name small.c
-mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-target-linker-version 2.24 -momit-leaf-frame-pointer -dwarf-column-info
-coverage-file /data2/c-hunter/test/small.c -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/3.8.0 -internal-isystem
/usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/3.8.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir
/data2/c-hunter/test -ferror-limit 19 -fmessage-length 114 -mstackrealign
-fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics
-vectorize-loops -vectorize-slp -o small.o -x c small.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'small.c'.
4.      Running pass 'Machine Block Frequency Analysis' on function '@fn1'
clang: error: unable to execute command: Aborted
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.8.0 (trunk 246931)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/tools/bin
clang: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ 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/small-248edd.c
clang: note: diagnostic msg: /tmp/small-248edd.sh
clang: note: diagnostic msg:

********************
$


-------------------------------------


int a, b, c, *d, e, f;

void
fn1 ()
{ 
  int g = 0;
  for (; b;)
    { 
      if (c)
        { 
          for (; 0; f++)
          lbl:
            ;
          for (e = -7; e < 38; e++)
            { 
              b ^= g && 1;
              if (b)
                goto lbl;
            }
        }
      if (a)
        goto lbl;
      for (;;)
        ;
    }
  d = &g;
}

-- 
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/20150905/a38b66e4/attachment-0001.html>


More information about the llvm-bugs mailing list