[all-commits] [llvm/llvm-project] 4082a7: Improve stack usage to increase recursive initiali...

Aaron Ballman via All-commits all-commits at lists.llvm.org
Tue Apr 16 10:48:35 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4082a7554521572a65a5a0008c4661a534df659d
      https://github.com/llvm/llvm-project/commit/4082a7554521572a65a5a0008c4661a534df659d
  Author: Aaron Ballman <aaron at aaronballman.com>
  Date:   2024-04-16 (Tue, 16 Apr 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Sema/Initialization.h
    M clang/include/clang/Sema/Overload.h
    M clang/lib/Sema/SemaInit.cpp
    M clang/lib/Sema/SemaOverload.cpp

  Log Message:
  -----------
  Improve stack usage to increase recursive initialization depth (#88546)

We were crashing due to stack exhaustion on rather reasonable C++
template code. After some investigation, I found that we have a
stack-allocated object that was huge: `InitializationSequence` was 7016
bytes. This caused an overflow with deep call stacks in initialization
code.

With these change, `InitializationSequence` is now 248 bytes.

With the original code, testing RelWithDebInfo on Windows 10, all the
tests in SemaCXX took about 6s 800ms. The max template depth I could
reach on my machine using the code in the issue was 708. After that, I
would get `-Wstack-exhausted` warnings until crashing at 976
instantiations.

With these changes on the same machine, all the tests in SemaCXX took
about 6s 500ms. The max template depth I could reach was 1492. After
that, I would get `-Wstack-exhausted` warnings until crashing at 2898
instantiations.

This improves the behavior of #88330 but there's still an outstanding
question of why we run out of stack space and crash in some
circumstances before we're able to issue a diagnostic about stack space
exhaustion.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list