<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Clang needs to truncate templated class names in crash reports"
   href="https://bugs.llvm.org/show_bug.cgi?id=41667">41667</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang needs to truncate templated class names in crash reports
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>rtrieu@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following code of recursive template instantiations exceeds the default
instantiation limit and runs out of memory.  This is pretty standard, but when
the crash report is printed, it will print every templated type expanded out. 
The code is only 6 lines long and the crash report is only 48 lines long, but
the full crash report is over 500 MB of text.  Some kind of limit on the line
length is needed to keep the crash report under a reasonable size.

$ cat long_test.ii
template <class, class>
struct a;
template <class b, class c, class d = b>
class e : e<a<b, c>, d> {};
e<long, long> f;

$ clang long_test.ii
long_test.ii:4:11: fatal error: recursive template instantiation exceeded
maximum depth of 1024
class e : e<a<b, c>, d> {};
          ^~~~~~~~~~~~~
LLVM ERROR: out of memory
Stack dump:
0.      Program arguments: /usr/local/bin/clang-9 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -discard-value-names -main-file-name long_test.ii
-mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno
-masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array
-target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -resource-dir
/usr/local/lib/clang/9.0.0 -fdeprecated-macro -fdebug-compilation-dir
/usr/local/crash -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -o
/tmp/long_test-8f6e8f.o -x c++-cpp-output long_test.ii -faddrsig 
1.      long_test.ii:5:16: current parser token ';'
2.      long_test.ii:4:7: instantiating class definition 'e<long, long, long>'
3.      long_test.ii:4:7: instantiating class definition 'e<a<long, long>,
long, a<long, long> >'
4.      long_test.ii:4:7: instantiating class definition 'e<a<a<long, long>,
long>, a<long, long>, a<a<long, long>, long> >'
5.      long_test.ii:4:7: instantiating class definition 'e<a<a<a<long, long>,
long>, a<long, long> >, a<a<long, long>, long>, a<a<a<long, long>, long>,
a<long, long> > >'
6.      long_test.ii:4:7: instantiating class definition 'e<a<a<a<a<long,
long>, long>, a<long, long> >, a<a<long, long>, long> >, a<a<a<long, long>,
long>, a<long, long> >, a<a<a<a<long, long>, long>, a<long, long> >, a<a<long,
long>, long> > >'
...
  Lines get longer and longer
...
clang-9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 9.0.0 (trunk 359392)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-9: note: diagnostic msg: PLEASE submit a bug report to
<a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash backtrace, preprocessed source,
and associated run script.
clang-9: note: diagnostic msg: Error generating preprocessed source(s) - no
preprocessable inputs.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>