[llvm-bugs] [Bug 51990] New: Stack overflow due to deep-level calls brought by deep-level child nodes during CodeGen.

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 28 00:12:10 PDT 2021


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

            Bug ID: 51990
           Summary: Stack overflow due to deep-level calls brought by
                    deep-level child nodes during CodeGen.
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: liuke.gehry at bytedance.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

When CodeGen processes AST nodes, there are many closed-loop calls, like
A->B->C->A->D->..., and the stack frame rollback is performed when the last
child node is processed. This will accumulate stack frames as the depth of the
child node increases. Finally, the stack overflows.
Here is a segmentation fault in the clang++ frontend. My system is Debian10,
x86-64. The version of clang++ is version 11.0.1

*****************
$ ulimit -s
8192

$ cat demo.cpp
#include <string>

const std::string str = "str";
const std::string A = "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "="
  "=" + str + "=" + str + "=" + str + "=" + str + "=";

$ clang++ -c demo.cpp
Segmentation fault (core dumped)
*****************

-- 
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/20210928/1e08c424/attachment-0001.html>


More information about the llvm-bugs mailing list