[llvm-bugs] [Bug 50352] New: clang memory hog with "LLVM ERROR: out of memory "

via llvm-bugs llvm-bugs at lists.llvm.org
Sat May 15 08:17:40 PDT 2021


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

            Bug ID: 50352
           Summary: clang memory hog with "LLVM ERROR: out of memory  "
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: haoxintu at gmail.com
                CC: llvm-bugs at lists.llvm.org

Hi all.

The following simple valid C program makes clang eat too much memory at
compile-time. This issue exists on Clang-12 onwards versions.

$cat small.c
#include <stdint.h>
int a, b, c;
void d() {
  int16_t e = 2;
  int16_t *f = e;
  for (*f = 20; *f; *f += 1)
    for (a = 5; a <= 51; a++)
      for (c = 3; c <= 83; c++)
        for (b = 8; b <= 85; b++) {
          static g = 2;
          int64_t *i = g;
          *i *= 3;
        }
}
void l() {
  uint16_t j;
  for (j = 27; j <= 33; j++)
    d();
}
void k() { l(); }

$ulimit -v 4096000 ; time clang -w -g -O3 small.c
LLVM ERROR: out of memory
Allocation failed
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments:
/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build/bin/clang-13
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations
-disable-free -main-file-name small.c -mrelocation-model static
-mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases
-munwind-tables -target-cpu x86-64 -tune-cpu generic -debug-info-kind=limited
-dwarf-version=4 -debugger-tuning=gdb
-fcoverage-compilation-dir=/home/haoxin/haoxin-data/dut-research/covsmith-test/test-0505
-resource-dir
/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build/lib/clang/13.0.0
-c-isystem /usr/local/include/csmith-2.3.0/ -internal-isystem
/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build/lib/clang/13.0.0/include
-internal-isystem /usr/local/include -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../x86_64-linux-gnu/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O3
-w
-fdebug-compilation-dir=/home/haoxin/haoxin-data/dut-research/covsmith-test/test-0505
-ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops
-vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-9a7482.o
-x c small.c
1.      <eof> parser at end of file
2.      Optimizer
LLVM ERROR: out of memory
Allocation failed
clang-13: error: unable to execute command: Aborted (core dumped)
clang-13: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 13.0.0 (https://github.com/llvm/llvm-project
ed339111bff690c6ba87d5e25c50bcad6793a309)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir:
/home/haoxin/haoxin-data/dut-research/compilers/llvm-project/build/bin
clang-13: note: diagnostic msg: 
********************

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

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

real    0m28.562s
user    0m26.230s
sys     0m2.224s


Reproduced in Godbolt: https://godbolt.org/z/Ke5Wx4PTe

Thanks,
Haoxin

-- 
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/20210515/b5d50228/attachment.html>


More information about the llvm-bugs mailing list