[llvm-bugs] [Bug 37446] New: clang crashes on valid code at -O3 on x86_64-linux-gnu: Assertion `BitPosition <= BitWidth && "BitPosition out of range"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Sun May 13 22:50:57 PDT 2018


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

            Bug ID: 37446
           Summary: clang crashes on valid code at -O3 on
                    x86_64-linux-gnu: Assertion `BitPosition <= BitWidth
                    && "BitPosition out of range"' failed
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: llvm-bugs at lists.llvm.org

Tested with trunk revision 332199. 


$ clangpolly -v
clang version 7.0.0 (http://llvm.org/git/clang.git
1064f0a9daefafcc3bb7b4d30f3a45b3b8770d99) (llvm/trunk 332199)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/su/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.4
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.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.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.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.2.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
$ 
$ 
$ clangpolly -O2 -c small.c
$ 
$ clangpolly -O3 -c small.c
clang-6.0: /home/su/software/tmp/polly/llvm/include/llvm/ADT/APInt.h:1388: void
llvm::APInt::setBit(unsigned int): Assertion `BitPosition <= BitWidth &&
"BitPosition out of range"' failed.
Stack dump:
0.      Program arguments: /home/su/software/tmp/polly/llvm_build/bin/clang-6.0
-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 -dwarf-column-info -debugger-tuning=gdb
-momit-leaf-frame-pointer -coverage-notes-file
/home/su/specres/good/20180513-clangpolly-m32-O3-g-build-112841/small.gcno
-resource-dir /home/su/software/tmp/polly/llvm_build/lib/clang/7.0.0
-internal-isystem /usr/local/include -internal-isystem
/home/su/software/tmp/polly/llvm_build/lib/clang/7.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/su/specres/good/20180513-clangpolly-m32-O3-g-build-112841 -ferror-limit
19 -fmessage-length 116 -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 'Combine pattern based expressions' on function '@g'
#0 0x000000000255a84a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/su/software/tmp/polly/llvm/lib/Support/Unix/Signals.inc:403:0
#1 0x00000000025589fe llvm::sys::RunSignalHandlers()
/home/su/software/tmp/polly/llvm/lib/Support/Signals.cpp:50:0
#2 0x0000000002558b60 SignalHandler(int)
/home/su/software/tmp/polly/llvm/lib/Support/Unix/Signals.inc:243:0
#3 0x00007f6f57c3e330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#4 0x00007f6f56a26c37 gsignal
/build/eglibc-SvCtMH/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f6f56a2a028 abort
/build/eglibc-SvCtMH/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f6f56a1fbf6 __assert_fail_base
/build/eglibc-SvCtMH/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f6f56a1fca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#8 0x00000000021a702a llvm::APInt::setBit(unsigned int)
/home/su/software/tmp/polly/llvm/include/llvm/ADT/APInt.h:1388:0
#9 0x00000000021a702a matchAndOrChain(llvm::Value*, MaskOps&)
/home/su/software/tmp/polly/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp:112:0
#10 0x00000000021a70a9 matchAndOrChain(llvm::Value*, MaskOps&)
/home/su/software/tmp/polly/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp:93:0
#11 0x00000000021a70a9 matchAndOrChain(llvm::Value*, MaskOps&)
/home/su/software/tmp/polly/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp:93:0
#12 0x00000000021a7814 foldAnyOrAllBitsSet
/home/su/software/tmp/polly/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp:137:0
#13 0x00000000021a7814 foldUnusualPatterns
/home/su/software/tmp/polly/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp:172:0
#14 0x00000000021a7814 runImpl(llvm::Function&, llvm::TargetLibraryInfo&,
llvm::DominatorTree&)
/home/su/software/tmp/polly/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp:190:0
#15 0x00000000020a5a9b llvm::FPPassManager::runOnFunction(llvm::Function&)
/home/su/software/tmp/polly/llvm/lib/IR/LegacyPassManager.cpp:1520:0
#16 0x0000000001b3d896 RunPassOnSCC
/home/su/software/tmp/polly/llvm/lib/Analysis/CallGraphSCCPass.cpp:156:0
#17 0x0000000001b3d896 RunAllPassesOnSCC
/home/su/software/tmp/polly/llvm/lib/Analysis/CallGraphSCCPass.cpp:424:0
#18 0x0000000001b3d896 (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)
/home/su/software/tmp/polly/llvm/lib/Analysis/CallGraphSCCPass.cpp:479:0
#19 0x00000000020a67aa runOnModule
/home/su/software/tmp/polly/llvm/lib/IR/LegacyPassManager.cpp:1597:0
#20 0x00000000020a67aa llvm::legacy::PassManagerImpl::run(llvm::Module&)
/home/su/software/tmp/polly/llvm/lib/IR/LegacyPassManager.cpp:1700:0
#21 0x000000000271588d ~PrettyStackTraceString
/home/su/software/tmp/polly/llvm/include/llvm/Support/PrettyStackTrace.h:52:0
#22 0x000000000271588d (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
/home/su/software/tmp/polly/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:815:0
#23 0x0000000002716d64 ~unique_ptr /usr/include/c++/4.9/bits/unique_ptr.h:235:0
#24 0x0000000002716d64 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/su/software/tmp/polly/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:1222:0
#25 0x0000000002f76c3c ~unique_ptr /usr/include/c++/4.9/bits/unique_ptr.h:235:0
#26 0x0000000002f76c3c
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
/home/su/software/tmp/polly/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:294:0
#27 0x000000000349cd4c clang::ParseAST(clang::Sema&, bool, bool)
/home/su/software/tmp/polly/llvm/tools/clang/lib/Parse/ParseAST.cpp:164:0
#28 0x0000000002f760d0 clang::CodeGenAction::ExecuteAction()
/home/su/software/tmp/polly/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:1044:0
#29 0x0000000002b20e46 clang::FrontendAction::Execute()
/home/su/software/tmp/polly/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:904:0
#30 0x0000000002af35e6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/su/software/tmp/polly/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:990:0
#31 0x0000000002bb8761
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/su/software/tmp/polly/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:255:0
#32 0x0000000000e0a290 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
/home/su/software/tmp/polly/llvm/tools/clang/tools/driver/cc1_main.cpp:222:0
#33 0x0000000000d8c221 ExecuteCC1Tool
/home/su/software/tmp/polly/llvm/tools/clang/tools/driver/driver.cpp:310:0
#34 0x0000000000d8c221 main
/home/su/software/tmp/polly/llvm/tools/clang/tools/driver/driver.cpp:382:0
#35 0x00007f6f56a11f45 __libc_start_main
/build/eglibc-SvCtMH/eglibc-2.19/csu/libc-start.c:321:0
#36 0x0000000000e06089 _start
(/home/su/software/tmp/polly/llvm_build/bin/clang-6.0+0xe06089)
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 7.0.0 (http://llvm.org/git/clang.git
1064f0a9daefafcc3bb7b4d30f3a45b3b8770d99) (llvm/trunk 332199)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/su/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/small-e1d591.c
clang-6.0: note: diagnostic msg: /tmp/small-e1d591.sh
clang-6.0: note: diagnostic msg: 

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


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


int b, d, e, f;

void g ()
{
  int h = 1, i = 33;
L1:
  if (!f)
    {
      i = 0;
      goto L2;
    }
  f = 15 & (1 >> i) & f;
L2:
  for (; e < 1; e++)
    {
      int n;
      if (b)
        continue;
      if (!d)
        break;
      if (!h)
        goto L1;
    }
}

-- 
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/20180514/95147593/attachment-0001.html>


More information about the llvm-bugs mailing list