Stack frames larger than 4K should be rejected, but what if I want more

IGotD- nise at nise.com
Sun Jun 27 21:08:32 UTC 2021


On Sunday, 27 June 2021 at 19:41:40 UTC, Ola Fosheim Grøstad 
wrote:
>
> It makes no sense and would kill a system level language. The 
> stack depth for Linux is 8MiB. 4KiB isn't even enough to fit a 
> commonly sized FFT buffer, anything less than 16KiB is a joke 
> IMHO.

Yes kind of, and I can think of use cases when you want big 
arrays on the stack. The question is if the approach is correct. 
Walter wants to catch potential memory corruption but limiting 
the stack usage (per function I assume) but in this case the real 
solution would be reading the stack limit (probably with an 
expensive system API but can be stored as a TLS variable).

On 64-bit systems there usually enough virtual space to put 
several megabytes of guard regions. On 32-bit systems it is more 
cramped and perhaps only 4K. The question is if this is something 
that should be dealt by the language.


More information about the Digitalmars-d mailing list