[llvm-bugs] [Bug 28062] New: clang crashes on valid code at -O2 and above on x86_64-linux-gnu with Assertion `Elt < getNumElements() && "Invalid Elt"' failed.

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 8 18:47:08 PDT 2016


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

            Bug ID: 28062
           Summary: clang crashes on valid code at -O2 and above on
                    x86_64-linux-gnu with Assertion `Elt <
                    getNumElements() && "Invalid Elt"' failed.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: helloqirun at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

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

It seems to be a 3.9 regression.

$ clang-trunk -v
clang version 3.9.0 (trunk 272124)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/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.3
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/3.4.6
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.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
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.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0
Found candidate GCC installation:
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/6.1.0
Found candidate GCC installation:
/usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.3.0
Selected GCC installation: /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/6.1.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64




$ clang-trunk -m32 -O2 abc.c -c
clang-3.9: /home/absozero/trunk/llvm/lib/IR/Constants.cpp:2327: const char
*llvm::ConstantDataSequential::getElementPointer(unsigned int) const: Assertion
`Elt < getNumElements() && "Invalid Elt"' failed.
#0 0x00000000019e9098 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x19e9098)
#1 0x00000000019e7296 llvm::sys::RunSignalHandlers()
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x19e7296)
#2 0x00000000019e976e SignalHandler(int)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x19e976e)
#3 0x00007f206ee8c340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007f206e03ecc9 gsignal
/build/buildd/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f206e0420d8 abort /build/buildd/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f206e037b86 __assert_fail_base
/build/buildd/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f206e037c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x00000000015670ef llvm::ConstantDataSequential::getElementPointer(unsigned
int) const (/home/absozero/trunk/root-clang/bin/clang-3.9+0x15670ef)
#9 0x0000000001567e07
llvm::ConstantDataSequential::getElementAsInteger(unsigned int) const
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1567e07)
#10 0x000000000155b34c
llvm::ConstantDataSequential::getElementAsConstant(unsigned int) const
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x155b34c)
#11 0x00000000023cbf09 llvm::UnrolledInstAnalyzer::visitLoad(llvm::LoadInst&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x23cbf09)
#12 0x00000000018ce87e llvm::InstVisitor<llvm::UnrolledInstAnalyzer,
bool>::visit(llvm::Instruction&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x18ce87e)
#13 0x00000000018cbb6e tryToUnrollLoop(llvm::Loop*, llvm::DominatorTree&,
llvm::LoopInfo*, llvm::ScalarEvolution*, llvm::TargetTransformInfo const&,
llvm::AssumptionCache&, bool, llvm::Optional<unsigned int>,
llvm::Optional<unsigned int>, llvm::Optional<bool>, llvm::Optional<bool>)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x18cbb6e)
#14 0x00000000018ca24f (anonymous
namespace)::LoopUnroll::runOnLoop(llvm::Loop*, llvm::LPPassManager&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x18ca24f)
#15 0x00000000023cd5ce llvm::LPPassManager::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x23cd5ce)
#16 0x00000000015d87bf llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x15d87bf)
#17 0x00000000023ac1a7 (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x23ac1a7)
#18 0x00000000015d8ef5 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x15d8ef5)
#19 0x0000000001b46477 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions
const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction,
llvm::raw_pwrite_stream*)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1b46477)
#20 0x000000000227df43
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x227df43)
#21 0x00000000026478f6 clang::ParseAST(clang::Sema&, bool, bool)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x26478f6)
#22 0x0000000001f1bbd5 clang::FrontendAction::Execute()
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1f1bbd5)
#23 0x0000000001ee3c91
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1ee3c91)
#24 0x0000000001fb5791
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1fb5791)
#25 0x0000000000762b7e cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/absozero/trunk/root-clang/bin/clang-3.9+0x762b7e)
#26 0x000000000076103d main
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x76103d)
#27 0x00007f206e029ec5 __libc_start_main
/build/buildd/eglibc-2.19/csu/libc-start.c:321:0
#28 0x000000000075e602 _start
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x75e602)
Stack dump:
0.    Program arguments: /home/absozero/trunk/root-clang/bin/clang-3.9 -cc1
-triple i386-unknown-linux-gnu -emit-obj -disable-free -main-file-name abc.c
-mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose
-mconstructor-aliases -fuse-init-array -target-cpu pentium4
-momit-leaf-frame-pointer -dwarf-column-info -debugger-tuning=gdb
-coverage-file /home/absozero/projects/reduction/crash/abc.c -resource-dir
/home/absozero/trunk/root-clang/bin/../lib/clang/3.9.0 -internal-isystem
/usr/local/include -internal-isystem
/home/absozero/trunk/root-clang/bin/../lib/clang/3.9.0/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O2
-fdebug-compilation-dir /home/absozero/projects/reduction/crash -ferror-limit
19 -fmessage-length 172 -fobjc-runtime=gcc -fdiagnostics-show-option
-fcolor-diagnostics -vectorize-loops -vectorize-slp -o abc.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 'Unroll loops' on basic block '%for.cond1.preheader'
clang-3.9: error: unable to execute command: Aborted (core dumped)
clang-3.9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.9.0 (trunk 272124)
Target: i386-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-3.9: 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-3.9: note: diagnostic msg:
********************

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

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



$ cat abc.c
static int a[4] = {7};
int b, c, d;
void fn1() {
  int e = -1;
  for (; e <= 3; e++) {
    c = 0;
    for (; c <= 3; c++)
      for (; b; b--)
        d = a[e];
  }
}

-- 
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/20160609/cc3fd525/attachment.html>


More information about the llvm-bugs mailing list