[LLVMbugs] [Bug 23540] New: clang crashes on valid code at -Os and above on x86_64-linux-gnu

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri May 15 13:35:34 PDT 2015


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

            Bug ID: 23540
           Summary: clang crashes on valid code at -Os and above 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 on
x86_64-linux-gnu at -Os and above in 64-bit mode (but not in 32-bit mode).

This is a regression from 3.6.x. 

$ clang-trunk -v
clang version 3.7.0 (trunk 237466)
Target: x86_64-unknown-linux-gnu
Thread model: posix
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.0.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.0.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 -m64 -O1 -c small.c
$ clang-trunk -m32 -Os -c small.c
$ clang-3.6.0 -m64 -Os -c small.c
$ 
$ clang-trunk -m64 -Os -c small.c
clang: /tmp/llvm/lib/Analysis/BasicAliasAnalysis.cpp:224: const llvm::Value*
GetLinearExpression(const llvm::Value*, llvm::APInt&, llvm::APInt&, unsigned
int&, unsigned int&, const llvm::DataLayout&, unsigned int,
llvm::AssumptionCache*, llvm::DominatorTree*, bool&, bool&): Assertion `Scale
== 0 && "Constant values don't have a scale"' failed.
#0 0x2d24cb8 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang+0x2d24cb8)
#1 0x2d23bfb (/usr/local/clang-trunk/bin/clang+0x2d23bfb)
#2 0x7f232df53340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#3 0x7f232cef1cc9 gsignal
/build/buildd/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#4 0x7f232cef50d8 abort /build/buildd/eglibc-2.19/stdlib/abort.c:91:0
#5 0x7f232ceeab86 __assert_fail_base
/build/buildd/eglibc-2.19/assert/assert.c:92:0
#6 0x7f232ceeac32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#7 0x295e028 (/usr/local/clang-trunk/bin/clang+0x295e028)
#8 0x295db46 (/usr/local/clang-trunk/bin/clang+0x295db46)
#9 0x2963450 (/usr/local/clang-trunk/bin/clang+0x2963450)
#10 0x296396c (/usr/local/clang-trunk/bin/clang+0x296396c)
#11 0x29525ad llvm::AliasSet::aliasesPointer(llvm::Value const*, unsigned long,
llvm::AAMDNodes const&, llvm::AliasAnalysis&) const
(/usr/local/clang-trunk/bin/clang+0x29525ad)
#12 0x2956228 llvm::AliasSetTracker::findAliasSetForPointer(llvm::Value const*,
unsigned long, llvm::AAMDNodes const&)
(/usr/local/clang-trunk/bin/clang+0x2956228)
#13 0x2957831 llvm::AliasSetTracker::getAliasSetForPointer(llvm::Value*,
unsigned long, llvm::AAMDNodes const&, bool*)
(/usr/local/clang-trunk/bin/clang+0x2957831)
#14 0x2958563 llvm::AliasSetTracker::add(llvm::AliasSetTracker const&)
(/usr/local/clang-trunk/bin/clang+0x2958563)
#15 0x275d8d5 (/usr/local/clang-trunk/bin/clang+0x275d8d5)
#16 0x29f71bf llvm::LPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang+0x29f71bf)
#17 0x2c96007 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang+0x2c96007)
#18 0x2938ece (/usr/local/clang-trunk/bin/clang+0x2938ece)
#19 0x2c979cf llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang+0x2c979cf)
#20 0xb534eb 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+0xb534eb)
#21 0xb40204 (/usr/local/clang-trunk/bin/clang+0xb40204)
#22 0xd5727a clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang+0xd5727a)
#23 0xb427b2 clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang+0xb427b2)
#24 0x959dd6 clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang+0x959dd6)
#25 0x9316ce clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang+0x9316ce)
#26 0x91689c clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang+0x91689c)
#27 0x90ed18 cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
(/usr/local/clang-trunk/bin/clang+0x90ed18)
#28 0x8f7f02 main (/usr/local/clang-trunk/bin/clang+0x8f7f02)
#29 0x7f232cedcec5 __libc_start_main
/build/buildd/eglibc-2.19/csu/libc-start.c:321:0
#30 0x90daad _start (/usr/local/clang-trunk/bin/clang+0x90daad)
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
-fno-unique-section-names -coverage-file
/data2/c-hunter-results/C/instrument-bugs/REDUCED/20150513-clang-trunk-m64-g-O3-build-094304/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 -Os -fdebug-compilation-dir
/data2/c-hunter-results/C/instrument-bugs/REDUCED/20150513-clang-trunk-m64-g-O3-build-094304
-ferror-limit 19 -fmessage-length 113 -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.    Per-module optimization passes
3.    Running pass 'CallGraph Pass Manager' on module 'small.c'.
4.    Running pass 'Loop Pass Manager' on function '@fn2'
5.    Running pass 'Loop Invariant Code Motion' on basic block '%for.cond'
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 237466)
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-63c579.c
clang: note: diagnostic msg: /tmp/small-63c579.sh
clang: note: diagnostic msg: 

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


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


int a, c[2], f;
unsigned int d;
volatile int e;

int
fn1 (int p)
{
  return p + a;
}

void
fn2 ()
{
  for (;;)
    {
      f++;
      for (; f;)
    {
      d = 0;
      f = e && fn1 (c[d+1]);
      if (c[d+1])
        a++;
    }
    }
}

-- 
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/20150515/f1e0b72f/attachment.html>


More information about the llvm-bugs mailing list