-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
__chkstk in debug and release-safe modes only and on all OSes #530
Comments
Stack size should large enough by default (say 10 MB instead of MSVC's 1 MB). For embedded application one could always set it lower. Certain version of AIX C++ compiler had default stack size 40 kB (yes, kilobytes) and it was big pain to find out why program (working elsewhere else) crashed. |
Large enough for what? You could have a recursive function use 9.9 MB and then call a function with a greater-than-page-size stack frame.
|
Large enough for big applications. LLVM itself uses 10 MB stack. I set it to 20 MB, to keep troubles away. I had never run out of stack due to recursion. Edit: I do not think |
Hi @PavelVozenilek, I am not sure I get the point of your comment. Stack is not actually allocated from main memory except on demand. The __chkstk function just makes sure that the local allocation of each function does not go past the guard page. It has nothing to do with the total amount of virtual memory address space that is allocated for the stack. Am I missing something??? I do like __chkstk. While I tend not to use large on-stack data, there is code that does with good effect. It is a great way to handle allocation without using malloc in C if your use cases can handle that approach. |
I did not run across an alloca() equivalent in Zig. If there is not, is stack allocation known statically on each function invocation at compile time? If so, then you could inject the equivalent of __chkstk only when you knew that there was a lot of data in the function's activation record. |
@kyle-github: I made aside remark, about usefullness of setting large stack limit. |
Status quo: when targeting windows, LLVM emits a call to __chkstk when the stack frame is larger than the guard page size, in all build modes. |
@andrewrk, cool. |
See #225 |
@andrewrk, Ah missed that one. Thanks. While alloca() is useful in some circumstances, it is easily abused. |
Looks like "probe-stack" is relevant: http://llvm.org/docs/LangRef.html#function-attributes |
__chkstk is a great idea, it causes a stack overflow to become a segfault. Let's do it on all OSes that we can, not just windows.
And let's turn it off for ReleaseFast mode.
The text was updated successfully, but these errors were encountered: