-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[Arm64] Implement stack probing using helper #13519
Comments
I was testing my implementation of stack probing using helpers on linux-arm and comparing its behavior with current implementation of the stack probing using inlined loops. I believe that the current implementation is under-probing one page. For example, below I have a disassembly of a funclet with large outgoing argument space (32712 bytes).
The thread stack ends at
Below is summary of what happens in the loop: Initial SP at the beginning of funclet prolog The funclet segfaults in the boby of funclet
The analysis is done on top of ef3180c |
When implementing printing stack trace at stack overflow, I have found that the fact that we don't move SP during the probing on Linux on ARM64 (as we haven't implemented the probing using helper for arm64) is causing a problem. To print the stack overflow stack, we need about 28kB of stack space. So when a stack overflow is detected in the SIGSEGV handler, we switch to a special preallocated stack of that size and run the exception handling on it. But when we hit a sigseg, we cannot get the actual stack limits as calling the function to get the limits is not allowed from an async signal handler when you don't know what code has triggered it. So we consider it to be a stack overflow based on whether the memory accessed was +/- a page around the SP. Then in both cases we run the common_signal_handler that is common for all hardware exceptions. At this point, it is possible that we only have a little over one memory page of stack space left if we are executing on the original stack. That is enough for checking if we are running in managed code and if we are, we can read the actual stack limits and detect the stack overflow even for probing without the helper. If the probing helper that moves SP while probing was implemented for arm64, this problem would go away as we would never hit this code path. |
@BruceForstall I take it you think this should stay in 5.0? |
Yes, @echesakovMSFT plans to get to it in 5.0 |
This should be moved to 6.0 - I won't have time to work on this |
I implemented the functionality of stack probing with helpers on arm64 and posted the changes in https://github.com/echesakovMSFT/runtime/tree/Arm64-Implement-Jit-StackProbe-Helper |
x86/x64 was implemented with dotnet/coreclr#26807. This issue tracks doing the work to implement it for arm32/arm64.
This would provide consistency in implementation, simplicity in the JIT stack probing implementation, as well as provide the benefits of stack probing exception stack traces for arm32/arm64.
Related: https://github.com/dotnet/coreclr/issues/21061
Update: Arm32 part of the issue is addressed in dotnet/coreclr#27184
For Arm64 we decided only to fix the stack probing loop (it currently under-probes one page) without implementing the helper.
In the future, we can implement the helper by following the suggested approach dotnet/coreclr#27184 (comment) but it is out of scope for the near term future
category:implementation
theme:prolog-epilog
skill-level:intermediate
cost:medium
The text was updated successfully, but these errors were encountered: