StackGuard when DotNetBuildUseMonoRuntime #19360
Merged
Conversation
Contributor
|
abonie
approved these changes
Feb 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add StackGuard for
visitSynExprunder Mono runtime + source-build CI for Mono configurationProblem
The
visitSynExprfunction inFileContentMapping.fsuses deep recursion through a continuation-passing stylevisitfunction. On Mono-based .NET runtimes (used in certain VMR source-build configurations), the default stack size is smaller, which can lead toStackOverflowExceptionwhen processing deeply nested syntax trees.Changes
Compiler: StackGuard for Mono runtime (
FileContentMapping.fs)When building with
DotNetBuildUseMonoRuntime=true, the recursivevisitfunction invisitSynExpris replaced with avisitGuardedvariant that usesStackGuardto check remaining stack space and spill to a new thread when needed. This is gated behind#if BUILD_USING_MONOso the CoreCLR path remains unchanged.open FSharp.Compiler.DiagnosticsLoggerforStackGuardaccess.BUILD_USING_MONO:visitGuardedtakes aStackGuardparameter; each recursivevisitcall goes throughsg.Guard(...).visitfunction is kept as-is with no overhead.Project: conditional
BUILD_USING_MONOdefine (FSharp.Compiler.Service.fsproj)Added
<DefineConstants>that setsBUILD_USING_MONOwhenDotNetBuildUseMonoRuntimeistrue, matching the convention used by the VMR (dotnet/dotnet) for Mono source-build scenarios.CI: second source-build platform for Mono configuration (
azure-pipelines-PR.yml)Added a
Managed_MonoRuntimesource-build platform that passes/p:DotNetBuildUseMonoRuntime=truealongside--source-build. This exercises the Mono code paths in PR CI. The property flows throughbuild.sh->eng/build.sh-> MSBuild via the existing/p:*pass-through mechanism.