[LLVMbugs] [Bug 22265] New: clang crashes on valid code at -O2 and -O3 on x86_64-linux-gnu

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jan 19 15:02:28 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22265

            Bug ID: 22265
           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: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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

It also affects all earlier versions of clang since 3.2. 

$ clang-trunk -v
clang version 3.7.0 (trunk 226434)
Target: x86_64-unknown-linux-gnu
Thread model: posix
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.1
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
$ 
$ clang-trunk -Os -c small.c
$ 
$ clang-trunk -O2 -c small.c
clang: /tmp/llvm/lib/CodeGen/ScheduleDAG.cpp:511: void
llvm::ScheduleDAGTopologicalSort::InitDAGTopologicalSorting(): Assertion
`Node2Index[SU->NodeNum] > Node2Index[I->getSUnit()->NodeNum] && "Wrong
topological sorting"' failed.
#0 0x2a3c3a8 llvm::sys::PrintStackTrace(_IO_FILE*)
(/usr/local/clang-trunk/bin/clang+0x2a3c3a8)
#1 0x2a3d8fb (/usr/local/clang-trunk/bin/clang+0x2a3d8fb)
#2 0x7ff0a1967cb0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0xfcb0)
#3 0x7ff0a0ca00d5 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x360d5)
#4 0x7ff0a0ca383b abort (/lib/x86_64-linux-gnu/libc.so.6+0x3983b)
#5 0x7ff0a0c98d9e (/lib/x86_64-linux-gnu/libc.so.6+0x2ed9e)
#6 0x7ff0a0c98e42 (/lib/x86_64-linux-gnu/libc.so.6+0x2ee42)
#7 0x23dc8ab llvm::ScheduleDAGTopologicalSort::InitDAGTopologicalSorting()
(/usr/local/clang-trunk/bin/clang+0x23dc8ab)
#8 0x21ff7c6 (/usr/local/clang-trunk/bin/clang+0x21ff7c6)
#9 0x2192447 llvm::SelectionDAGISel::CodeGenAndEmitDAG()
(/usr/local/clang-trunk/bin/clang+0x2192447)
#10 0x2190a80 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function
const&) (/usr/local/clang-trunk/bin/clang+0x2190a80)
#11 0x218d74a
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/usr/local/clang-trunk/bin/clang+0x218d74a)
#12 0x1f91896 (/usr/local/clang-trunk/bin/clang+0x1f91896)
#13 0x2330a6c llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang+0x2330a6c)
#14 0x29bcda1 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang+0x29bcda1)
#15 0x29bcfdb llvm::FPPassManager::runOnModule(llvm::Module&)
(/usr/local/clang-trunk/bin/clang+0x29bcfdb)
#16 0x29bd4b5 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang+0x29bd4b5)
#17 0x9134ed clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions
const&, llvm::StringRef, llvm::Module*, clang::BackendAction,
llvm::raw_ostream*) (/usr/local/clang-trunk/bin/clang+0x9134ed)
#18 0x907be5 (/usr/local/clang-trunk/bin/clang+0x907be5)
#19 0xaf8973 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang+0xaf8973)
#20 0x7094ee clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang+0x7094ee)
#21 0x6dc01c clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang+0x6dc01c)
#22 0x6bd86a clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang+0x6bd86a)
#23 0x6b43f2 cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
(/usr/local/clang-trunk/bin/clang+0x6b43f2)
#24 0x6bbecb main (/usr/local/clang-trunk/bin/clang+0x6bbecb)
#25 0x7ff0a0c8b76d __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2176d)
#26 0x6b4059 _start (/usr/local/clang-trunk/bin/clang+0x6b4059)
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.22 -momit-leaf-frame-pointer -dwarf-column-info
-coverage-file /home/su/small.c -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/3.7.0 -internal-isystem
/usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/3.7.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir /home/su
-ferror-limit 19 -fmessage-length 93 -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 'X86 DAG->DAG Instruction Selection' on function '@fn2'
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.7.0 (trunk 226434)
Target: x86_64-unknown-linux-gnu
Thread model: posix
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-364ce1.c
clang: note: diagnostic msg: /tmp/small-364ce1.sh
clang: note: diagnostic msg: 

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


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


volatile short a;
int b, c, d, e;

short
fn1 (int p)
{
  b++;
  for (e = 0; e < 2; e++)
    if (b)
      p = 0;
  return p;
}

void
fn2 ()
{
  d = fn1 (a);
  c = d == 0;
}

-- 
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/20150119/977aab81/attachment.html>


More information about the llvm-bugs mailing list