[llvm-bugs] [Bug 51712] New: Clang runs OOM when checking for constant initialization of array

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 2 01:49:03 PDT 2021


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

            Bug ID: 51712
           Summary: Clang runs OOM when checking for constant
                    initialization of array
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kadircetinkaya.06.tr at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

```
cat > a.cc <<EOF
struct {
  int a, b, c, d;
} arr[50][6000000];
EOF
clang -fsyntax-only -xc++ a.cc
```

Results in clang consuming huge memory (tried with ~190GiB) and OOMing in the
end. A sample backtrace looks like:
```
#0  getDefaultInitValue () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:4733
#1  0x0000000004e75412 in getDefaultInitValue () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:4726
#2  0x0000000004ed80ae in VisitCXXConstructExpr () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:10484
#3  0x0000000004ed8283 in VisitCXXConstructExpr () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:10471
#4  0x0000000004ed8283 in VisitCXXConstructExpr () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:10471
#5  0x0000000004e7259b in EvaluateArray () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:10298
#6  EvaluateInPlace () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:14463
#7  0x0000000004e74596 in EvaluateAsInitializer () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:14725
#8  0x0000000004ddf0ef in evaluateValueImpl () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/Decl.cpp:2389
#9  0x0000000004ddf287 in checkForConstantInitialization () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/Decl.cpp:2460
#10 0x0000000004507705 in CheckCompleteVariableDeclaration () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Sema/SemaDecl.cpp:13007
#11 0x00000000044ea30b in ActOnUninitializedDecl () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Sema/SemaDecl.cpp:12704
#12 0x00000000042ec53d in ParseDeclarationAfterDeclaratorAndAttributes () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/ParseDecl.cpp:2387
#13 0x00000000042eaa9d in ParseDeclGroup () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/ParseDecl.cpp:2038
#14 0x00000000042caa9c in ParseDeclOrFunctionDefInternal () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/Parser.cpp:1135
#15 0x00000000042ca4e5 in ParseDeclarationOrFunctionDefinition () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/Parser.cpp:1151
#16 0x00000000042c91ee in ParseExternalDeclaration () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/Parser.cpp:971
#17 0x00000000042c6e34 in ParseTopLevelDecl () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/Parser.cpp:716
#18 0x00000000042c65b7 in ParseFirstTopLevelDecl () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/Parser.cpp:588
#19 0x00000000042c1321 in ParseAST () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/ParseAST.cpp:157
#20 0x000000000312399d in Execute () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Frontend/FrontendAction.cpp:949
#21 0x00000000030b35e2 in ExecuteAction () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Frontend/CompilerInstance.cpp:989
#22 0x00000000031d6a62 in ExecuteCompilerInvocation () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278
#23 0x00000000009e8703 in cc1_main () at
/usr/local/google/home/kadircet/repos/llvm/clang/tools/driver/cc1_main.cpp:240
#24 0x00000000009e66fc in ExecuteCC1Tool () at
/usr/local/google/home/kadircet/repos/llvm/clang/tools/driver/driver.cpp:330
#25 0x0000000002f5cb32 in operator() () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Driver/Job.cpp:404
#26 callback_fn<(lambda at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Driver/Job.cpp:404:22)>(void)
() at
/usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/ADT/STLExtras.h:185
#27 0x0000000002870041 in operator() () at
/usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/ADT/STLExtras.h:209
#28 RunSafely () at
/usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/CrashRecoveryContext.cpp:424
#29 0x0000000002f5c1f7 in Execute () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Driver/Job.cpp:404
#30 0x0000000002f272c8 in ExecuteCommand () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Driver/Compilation.cpp:195
#31 0x0000000002f27817 in ExecuteJobs () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Driver/Compilation.cpp:246
#32 0x0000000002f41c88 in ExecuteCompilation () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Driver/Driver.cpp:1510
#33 0x00000000009e5df4 in main () at
/usr/local/google/home/kadircet/repos/llvm/clang/tools/driver/driver.cpp:502
```

All of the backtrace samples I grabbed had `checkForConstantInitialization` as
LCA.

-- 
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/20210902/95164231/attachment.html>


More information about the llvm-bugs mailing list