-
Notifications
You must be signed in to change notification settings - Fork 13
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
su_use_stack redundant? #12
Comments
Hi @iangehc - thanks for suggesting improvements! |
With optimization enabled, the compiler may elide the stack based array allocated by su_use_stack, thus causing this function to run for a very long time. Tested on Ubuntu 16.04.6 (i386, kernel 4.15.0-45-generic, gcc 5.4.0). Tested on custom Yocto (i.MX53, kernel 5.15.22, gcc 9.3.0). Tested on macOS Catalina (Apple clang version clang-1200.0.32.29). Signed-off-by: Ian Ray <ian.ray@ge.com>
Thanks for the reference to #1 -- that was useful to re-create the issue on an Ubuntu VM. The pull request differs from what I initially planned, as the issue seems to be related to optimization of the dummy array. |
Disable optimization in su_use_stack (#12)
Hi,
su_use_stack() appears to be redundant because the call to memset() is followed by filling the stack byte-by-byte and, in both cases, if a page is not mapped then the OS will catch a page fault and map the requested page.
Was there a particular OS/kernel version that you had in mind when creating su_use_stack()?
Would you accept a patch to remove this function?
Thank for making this very useful tool!
System
i.MX53 (ARM Cortex-A8, ARMv7-A) running custom Yocto (Dunfell, gcc 9.3.0, kernel 5.15) with stack size 100000 and a main thread of 8 MiB.
Debug Patch
Debug Output
As we recurse, the address of
here
grows by only 40 bytes.(I assume this is due to a compiler optimisation, since
arr
is 16 KiB.)Given main thread size of 8386960, then this implies 8386960/40 or > 200K function calls.
(On my system I stopped waiting after many minutes.)
The text was updated successfully, but these errors were encountered: