Implement icall used by RuntimeHelpers.EnsureSufficientExecutionStack on netcore Mono. #33857
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current implementation always returned true for Windows/Linux/Android. There are however use of this API in Task library to make sure recursive tasks won't hit stackoverflow. There are several tests in System.Threading.Tasks that currently hit this, at least on Windows, causing test failures.
Fix use stack limits already setup in register_thread and used by GC when doing conservative stack scan. If the limits have not been setup or is not supported on platform, we will use old defaults, always assume there is enough stack space available. Heuristics around size of minimum execution
stack needed are picked from corresponding CoreCLR implementation.
With this fix all tests run in System.Threading.Tasks.Tests pass on Windows using Mono runtime:
Before fix the following tests hit stackoverflow:
LongContinuationChain_ContinueWith_DoesNotStackOverflow
LongContinuationChain_Unwrap_DoesNotStackOverflow
LongContinuationChain_Await_DoesNotStackOverflow
RunStackGuardTests