[clang] [Serialization] Check for stack exhaustion when reading declarations (PR #79875)

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 3 08:05:44 PDT 2024


ilya-biryukov wrote:

I have tried `ulimit` and found that Clang relies on a very intricate balance between the stack size, the desired stack size (the cutoff at which we create a new thread with a larger stack) and the points in code where we call `runWithSufficientStackSpace`.

If the stack limit is very small, we crash on some other code path or even do something weird in the code path checking for stack exhaustion (it currently checks if there's less than 256K stack available, clearly not the right thing if I request a stack of 128K with ulimit in the first place).
If the stack limit is larger, the amount of code required to trigger the crash is high and the test is too slow for checking in (IMO).

I think @ChuanqiXu9 's suggestion of making the parameters (desireableStackSize, in particular) of these checks customizable for unit testing would allow to have a more fine-grained knob and actually have a test for this. I'll try to experiment with this approach and report my findings.

In the meantime, I have addressed the last comment and plan to land this without tests for now.

https://github.com/llvm/llvm-project/pull/79875


More information about the cfe-commits mailing list