[llvm-bugs] [Bug 33994] New: clang crashes with Assertion `idx < size()' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jul 30 10:30:48 PDT 2017


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

            Bug ID: 33994
           Summary: clang crashes with Assertion `idx < size()' failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            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

The following code crashes the current trunk version at "-O3".

The crash is similar to bug 33142. But that one cannot reproduce anymore.



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


$ clang-trunk -O3 abc.c
abc.c:12:11: warning: incompatible pointer types assigning to 'int *' from
'void (char)' [-Wincompatible-pointer-types]
        b = fn1;
          ^ ~~~
clang-6.0: /home/absozero/trunk/llvm/include/llvm/ADT/SmallVector.h:149:
llvm::SmallVectorTemplateCommon::reference
llvm::SmallVectorTemplateCommon<llvm::Value *,
void>::operator[](llvm::SmallVectorTemplateCommon::size_type) [T = llvm::Value
*]: Assertion `idx < size()' failed.
#0 0x0000000001cc1d14 PrintStackTraceSignalHandler(void*)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x1cc1d14)
#1 0x0000000001cc2036 SignalHandler(int)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x1cc2036)
#2 0x00007f8cf6941330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#3 0x00007f8cf54bec37 gsignal
/build/eglibc-oGUzwX/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#4 0x00007f8cf54c2028 abort
/build/eglibc-oGUzwX/eglibc-2.19/stdlib/abort.c:91:0
#5 0x00007f8cf54b7bf6 __assert_fail_base
/build/eglibc-oGUzwX/eglibc-2.19/assert/assert.c:92:0
#6 0x00007f8cf54b7ca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#7 0x00000000012e2605 llvm::BasicAAResult::aliasPHI(llvm::PHINode const*,
unsigned long, llvm::AAMDNodes const&, llvm::Value const*, unsigned long,
llvm::AAMDNodes const&, llvm::Value const*)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x12e2605)
#8 0x00000000012deedf llvm::BasicAAResult::aliasCheck(llvm::Value const*,
unsigned long, llvm::AAMDNodes, llvm::Value const*, unsigned long,
llvm::AAMDNodes, llvm::Value const*, llvm::Value const*)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x12deedf)
#9 0x00000000012de7a0 llvm::BasicAAResult::alias(llvm::MemoryLocation const&,
llvm::MemoryLocation const&)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x12de7a0)
#10 0x00000000012ce0b0 llvm::AAResults::getModRefInfo(llvm::StoreInst const*,
llvm::MemoryLocation const&)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x12ce0b0)
#11 0x000000000137ba08 llvm::FindAvailablePtrLoadStore(llvm::Value*,
llvm::Type*, bool, llvm::BasicBlock*,
llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true,
false, void>, false, false>&, unsigned int, llvm::AAResults*, bool*, unsigned
int*) (/home/absozero/trunk/root-clang/bin/clang-6.0+0x137ba08)
#12 0x0000000001b14d47
llvm::JumpThreadingPass::SimplifyPartiallyRedundantLoad(llvm::LoadInst*)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x1b14d47)
#13 0x0000000001b0faab llvm::JumpThreadingPass::ProcessBlock(llvm::BasicBlock*)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x1b0faab)
#14 0x0000000001b0f0a0 llvm::JumpThreadingPass::runImpl(llvm::Function&,
llvm::TargetLibraryInfo*, llvm::LazyValueInfo*, llvm::AAResults*, bool,
std::unique_ptr<llvm::BlockFrequencyInfo,
std::default_delete<llvm::BlockFrequencyInfo> >,
std::unique_ptr<llvm::BranchProbabilityInfo,
std::default_delete<llvm::BranchProbabilityInfo> >)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x1b0f0a0)
#15 0x0000000001b1b04d (anonymous
namespace)::JumpThreading::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x1b1b04d)
#16 0x00000000018349ef llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x18349ef)
#17 0x0000000001302c09 (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x1302c09)
#18 0x0000000001835126 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x1835126)
#19 0x0000000001e3d95b 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-6.0+0x1e3d95b)
#20 0x000000000257d7f2
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x257d7f2)
#21 0x00000000029f6ab6 clang::ParseAST(clang::Sema&, bool, bool)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x29f6ab6)
#22 0x0000000002235098 clang::FrontendAction::Execute()
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x2235098)
#23 0x00000000021e4ac1
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x21e4ac1)
#24 0x00000000022bf687
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x22bf687)
#25 0x0000000000855554 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/absozero/trunk/root-clang/bin/clang-6.0+0x855554)
#26 0x00000000008530f1 main
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x8530f1)
#27 0x00007f8cf54a9f45 __libc_start_main
/build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:321:0
#28 0x00000000008501f9 _start
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x8501f9)
Stack dump:
0.      Program arguments: /home/absozero/trunk/root-clang/bin/clang-6.0 -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
-momit-leaf-frame-pointer -dwarf-column-info -debugger-tuning=gdb -resource-dir
/home/absozero/trunk/root-clang/lib/clang/6.0.0 -internal-isystem
/usr/local/include -internal-isystem
/home/absozero/trunk/root-clang/lib/clang/6.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O3
-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 /tmp/abc-b0fb95.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 'Jump Threading' on function '@fn1'
clang-6.0: error: unable to execute command: Aborted (core dumped)
clang-6.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 6.0.0 (trunk 309507)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-6.0: 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-6.0: note: diagnostic msg:
********************

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

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


$ cat abc.c
volatile int a, d;
int *b;
int c;
void fn1(char p1) {
  int *e = &c;
  for (;;) {
    for (; c; ++d)
      ;
    p1 || a;
    for (; c < 9;)
      if (b) {
        b = fn1;
        *e = 0;
      }
    *b = 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/20170730/42ce248d/attachment-0001.html>


More information about the llvm-bugs mailing list