Skip to content

Stack overflow typechecking large CEs on macOS #13084

Closed

Description

@samritchie

Upgrading from FSAC v0.51.0 to v0.52.0 (Ionide 6.0.0) triggers a stack overflow in FSharp.Compiler.CheckComputationExpressions on macOS when attempting to typecheck a file containing large CEs.

I saw similar issues a couple of years ago with early versions of the netcore FSAC. Tracing through the versions, it looks like there may have been a performance regression between FCS 41.0.1 and 41.0.3?

Repro steps

Open the following file on macOS

#r "nuget: Chiron"

open Chiron

type LargeRecord =
    {
        Property1: string
        Property2: string
        Property3: string
        Property4: string
        Property5: string
        Property6: string
        Property7: string
        Property8: string
        Property9: string
        Property10: string
        Property11: string
        Property12: string
        Property13: string
        Property14: string
        Property15: string
        Property16: string
        Property17: string
        Property18: string
        Property19: string
        Property20: string
        Property21: string
        Property22: string
        Property23: string
        Property24: string
        Property25: string
        Property26: string
        Property27: string
        Property28: string
        Property29: string
        Property30: string
        Property31: string
        Property32: string
        Property33: string
        Property34: string
        Property35: string
        Property36: string
        Property37: string
    }
    with
    static member ToJson(x: LargeRecord) = json {
        do! Json.write "property1" x.Property1
        do! Json.write "property2" x.Property2
        do! Json.write "property3" x.Property3
        do! Json.write "property4" x.Property4
        do! Json.write "property5" x.Property5
        do! Json.write "property6" x.Property6
        do! Json.write "property7" x.Property7
        do! Json.write "property8" x.Property8
        do! Json.write "property9" x.Property9
        do! Json.write "property10" x.Property10
        do! Json.write "property11" x.Property11
        do! Json.write "property12" x.Property12
        do! Json.write "property13" x.Property13
        do! Json.write "property14" x.Property14
        do! Json.write "property15" x.Property15
        do! Json.write "property16" x.Property16
        do! Json.write "property17" x.Property17
        do! Json.write "property18" x.Property18
        do! Json.write "property19" x.Property19
        do! Json.write "property20" x.Property20
        do! Json.write "property21" x.Property21
        do! Json.write "property22" x.Property22
        do! Json.write "property23" x.Property23
        do! Json.write "property24" x.Property24
        do! Json.write "property25" x.Property25
        do! Json.write "property26" x.Property26
        do! Json.write "property27" x.Property27
        do! Json.write "property28" x.Property28
        do! Json.write "property29" x.Property29
        do! Json.write "property30" x.Property30
        do! Json.write "property31" x.Property31
        do! Json.write "property32" x.Property32
        do! Json.write "property33" x.Property33
        do! Json.write "property34" x.Property34
        do! Json.write "property35" x.Property35
        do! Json.write "property36" x.Property36
        do! Json.write "property37" x.Property37
    }

Expected behavior

File typechecks successfully

Actual behavior

Language server crashes and reports a stack overflow starting with:

Stack overflow.
   at FSharp.Compiler.Syntax.DebugPointAtLeafExpr.NewYes(FSharp.Compiler.Text.Range)
   at FSharp.Compiler.CheckComputationExpressions.convertSimpleReturnToExpr@1668(TcFileState, UnscopedTyparEnv, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.SynExpr, TType, AccessorDomain, System.String, Boolean, Microsoft.FSharp.Collections.FSharpList`1<MethInfo>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, TcEnv, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, Boolean, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, FSharp.Compiler.Syntax.SynExpr)
   at FSharp.Compiler.CheckComputationExpressions.transBind@1630(TcFileState, UnscopedTyparEnv, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.SynExpr, TType, AccessorDomain, System.String, Boolean, Microsoft.FSharp.Collections.FSharpList`1<MethInfo>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, TcEnv, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, Boolean, CustomOperationsMode, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, FSharp.Compiler.Text.Range, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.SynExpr,FSharp.Compiler.Syntax.SynExpr>, System.String, Microsoft.FSharp.Collections.FSharpList`1<FSharp.Compiler.Syntax.SynExpr>, FSharp.Compiler.Syntax.SynPat, FSharp.Compiler.Syntax.SynExpr, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.SynExpr,FSharp.Compiler.Syntax.SynExpr>)
   at FSharp.Compiler.CheckComputationExpressions+tryTrans@776-1.Invoke(Microsoft.FSharp.Core.Unit)
   at FSharp.Compiler.ErrorLogger+StackGuard.Guard[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.Unit,System.__Canon>)
   at FSharp.Compiler.CheckComputationExpressions.tryTrans@774(TcFileState, UnscopedTyparEnv, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.SynExpr, TType, AccessorDomain, System.String, Boolean, Microsoft.FSharp.Collections.FSharpList`1<MethInfo>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, TcEnv, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, Boolean, CompExprTranslationPass, CustomOperationsMode, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, FSharp.Compiler.Syntax.SynExpr, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.SynExpr,FSharp.Compiler.Syntax.SynExpr>)
   at FSharp.Compiler.CheckComputationExpressions.trans@1589-2(TcFileState, UnscopedTyparEnv, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.SynExpr, TType, AccessorDomain, System.String, Boolean, Microsoft.FSharp.Collections.FSharpList`1<MethInfo>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, TcEnv, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, Boolean, CompExprTranslationPass, CustomOperationsMode, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, FSharp.Compiler.Syntax.SynExpr, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.SynExpr,FSharp.Compiler.Syntax.SynExpr>)
   at FSharp.Compiler.CheckComputationExpressions.transBind@1630(TcFileState, UnscopedTyparEnv, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.SynExpr, TType, AccessorDomain, System.String, Boolean, Microsoft.FSharp.Collections.FSharpList`1<MethInfo>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, TcEnv, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, Boolean, CustomOperationsMode, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, FSharp.Compiler.Text.Range, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.SynExpr,FSharp.Compiler.Syntax.SynExpr>, System.String, Microsoft.FSharp.Collections.FSharpList`1<FSharp.Compiler.Syntax.SynExpr>, FSharp.Compiler.Syntax.SynPat, FSharp.Compiler.Syntax.SynExpr, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.SynExpr,FSharp.Compiler.Syntax.SynExpr>)
   at FSharp.Compiler.CheckComputationExpressions+tryTrans@776-1.Invoke(Microsoft.FSharp.Core.Unit)
   at FSharp.Compiler.ErrorLogger+StackGuard.Guard[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.Unit,System.__Canon>)
   at FSharp.Compiler.CheckComputationExpressions.tryTrans@774(TcFileState, UnscopedTyparEnv, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.SynExpr, TType, AccessorDomain, System.String, Boolean, Microsoft.FSharp.Collections.FSharpList`1<MethInfo>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, TcEnv, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, Boolean, CompExprTranslationPass, CustomOperationsMode, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, FSharp.Compiler.Syntax.SynExpr, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.SynExpr,FSharp.Compiler.Syntax.SynExpr>)
   at FSharp.Compiler.CheckComputationExpressions.trans@1589-2(TcFileState, UnscopedTyparEnv, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.SynExpr, TType, AccessorDomain, System.String, Boolean, Microsoft.FSharp.Collections.FSharpList`1<MethInfo>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, TcEnv, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, Boolean, CompExprTranslationPass, CustomOperationsMode, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, FSharp.Compiler.Syntax.SynExpr, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.SynExpr,FSharp.Compiler.Syntax.SynExpr>)
   at FSharp.Compiler.CheckComputationExpressions+tryTrans@776-1.Invoke(Microsoft.FSharp.Core.Unit)
   at FSharp.Compiler.ErrorLogger+StackGuard.Guard[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.Unit,System.__Canon>)
   at FSharp.Compiler.CheckComputationExpressions.tryTrans@774(TcFileState, UnscopedTyparEnv, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.SynExpr, TType, AccessorDomain, System.String, Boolean, Microsoft.FSharp.Collections.FSharpList`1<MethInfo>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, TcEnv, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, Boolean, CompExprTranslationPass, CustomOperationsMode, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, FSharp.Compiler.Syntax.SynExpr, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.SynExpr,FSharp.Compiler.Syntax.SynExpr>)
   at FSharp.Compiler.CheckComputationExpressions.trans@1589-2(TcFileState, UnscopedTyparEnv, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.SynExpr, TType, AccessorDomain, System.String, Boolean, Microsoft.FSharp.Collections.FSharpList`1<MethInfo>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, TcEnv, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, Boolean, CompExprTranslationPass, CustomOperationsMode, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, FSharp.Compiler.Syntax.SynExpr, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.SynExpr,FSharp.Compiler.Syntax.SynExpr>)
   at FSharp.Compiler.CheckComputationExpressions.transBind@1630(TcFileState, UnscopedTyparEnv, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.SynExpr, TType, AccessorDomain, System.String, Boolean, Microsoft.FSharp.Collections.FSharpList`1<MethInfo>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, TcEnv, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, Boolean, CustomOperationsMode, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, FSharp.Compiler.Text.Range, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.SynExpr,FSharp.Compiler.Syntax.SynExpr>, System.String, Microsoft.FSharp.Collections.FSharpList`1<FSharp.Compiler.Syntax.SynExpr>, FSharp.Compiler.Syntax.SynPat, FSharp.Compiler.Syntax.SynExpr, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.SynExpr,FSharp.Compiler.Syntax.SynExpr>)
   at FSharp.Compiler.CheckComputationExpressions+tryTrans@776-1.Invoke(Microsoft.FSharp.Core.Unit)
   at FSharp.Compiler.ErrorLogger+StackGuard.Guard[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.Unit,System.__Canon>)
   at FSharp.Compiler.CheckComputationExpressions.tryTrans@774(TcFileState, UnscopedTyparEnv, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.SynExpr, TType, AccessorDomain, System.String, Boolean, Microsoft.FSharp.Collections.FSharpList`1<MethInfo>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, TcEnv, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, Boolean, CompExprTranslationPass, CustomOperationsMode, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, FSharp.Compiler.Syntax.SynExpr, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.SynExpr,FSharp.Compiler.Syntax.SynExpr>)
   at FSharp.Compiler.CheckComputationExpressions.trans@1589-2(TcFileState, UnscopedTyparEnv, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.SynExpr, TType, AccessorDomain, System.String, Boolean, Microsoft.FSharp.Collections.FSharpList`1<MethInfo>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, System.Collections.Generic.IDictionary`2<System.String,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`8<System.String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`2<Microsoft.FSharp.Core.FSharpOption`1<System.String>,MethInfo>>>>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.Ident,Boolean>, TcEnv, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, Boolean, CompExprTranslationPass, CustomOperationsMode, Internal.Utilities.Library.LazyWithContext`2<System.Tuple`2<Microsoft.FSharp.Collections.FSharpList`1<Val>,TcEnv>,FSharp.Compiler.Text.Range>, FSharp.Compiler.Syntax.SynExpr, Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.SynExpr,FSharp.Compiler.Syntax.SynExpr>)
   at FSharp.Compiler.CheckComputationExpressions+tryTrans@776-1.Invoke(Microsoft.FSharp.Core.Unit)

Known workarounds

Setting the environment variable COMPlus_DefaultStackSize=180000 allows typecheck to complete successfully

Related information

  • Operating system: macOS 12.3.1 on an M1 machine; I've also reproduced on macOS x86_64 although I needed about 10 more do! expressions
  • .NET Runtime: 6.0.201 (arm64 version)
.NET SDK (reflecting any global.json):
 Version:   6.0.201
 Commit:    ef40e6aa06

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  12.3
 OS Platform: Darwin
 RID:         osx.12-arm64
 Base Path:   /usr/local/share/dotnet/sdk/6.0.201/

Host (useful for support):
  Version: 6.0.3
  Commit:  c24d9a9c91

.NET SDKs installed:
  6.0.201 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  • Editing Tools: VS Code 1.66.2 with Ionide 6.0.3

Activity

  1. vzarytovskii commented on May 3, 2022

    @vzarytovskii
    Member

    This may have been fixed in #12420
    I will test it in latest dev17.3, everything from 17.2 should be there.
    Although, I'm not sure whether we've released FCS since the fix, @KevinRansom?

    CC @dsyme FYI

  2. samritchie commented on May 6, 2022

    @samritchie
    Author

    I'm not sure how to tell which PRs are in which release, but the performance appears to have regressed between 41.0.1 (released 6 months ago) and 41.0.3 (released 2 months ago)

  3. dsyme commented on May 16, 2022

    @dsyme
    Contributor

    I'm not sure how to tell which PRs are in which release, but the performance appears to have regressed between 41.0.1 (released 6 months ago) and 41.0.3 (released 2 months ago)

    It would be good to have separate issues for the stackoverflow and any perf regression, thanks. Is the perf regression specifically with the kind of large-input code above?

  4. added
    Area-Compiler-Checking
    Impact-High
    on May 16, 2022
  5. samritchie commented on May 16, 2022

    @samritchie
    Author

    Sorry, 'performance' was the wrong word - I meant the previous version (41.0.1) was okay with this code, the stack overflow was introduced some time after then.

    I've been describing it a regression as I'm pretty sure it is the same issue I had with this same code a couple of years ago - it prevented me switching from mono FSAC to netcore FSAC for a good year or so.

  6. added
    Impact-Medium
    and removed
    Impact-High
    on Aug 16, 2022
  7. dsyme commented on Aug 16, 2022

    @dsyme
    Contributor

    @samritchie Could you set the environment variable FSHARP_TcStackGuardDepth=50 in your command prompt prior to building and see if you continue to repro this? Thanks

    It might be we just have to reduce this stack guard, either on all or on MacOS:

    #if DEBUG
    let TcStackGuardDepth = GetEnvInteger "FSHARP_TcStackGuardDepth" 40
    #else
    let TcStackGuardDepth = GetEnvInteger "FSHARP_TcStackGuardDepth" 80
    #endif
    
  8. samritchie commented on Aug 17, 2022

    @samritchie
    Author

    @dsyme FSHARP_TcStackGuardDepth=50 prevents the crash, at least on Ionide 6.0/FSAC 0.54. Sorry, it’s been difficult to confirm, there appears to be a fresh issue in Ionide 7.0/FSAC 0.56 where typecheck looks like it is looping endlessly. I'll see if I can block out some time next week to do a repro.

  9. dsyme commented on Aug 17, 2022

    @dsyme
    Contributor

    Thanks for confirming.

    I'll see if I can block out some time next week to do a repro.

    Please do, if there's been a regression we'd like to know about it ASAP, thanks

  10. samritchie commented on Aug 30, 2022

    @samritchie
    Author

    I've upgraded to Ionide 7.1.0/FSAC 0.56.2 and intellisense is not instant but is at least usable - possibly it was related to this: ionide/FsAutoComplete#977. This version still crashes with an SO opening the repro file without the FSHARP_TcStackGuardDepth workaround.

  11. added this to the Backlog milestone on Sep 21, 2022
  12. github-actions commented on Oct 15, 2026

    @github-actions
    Contributor

    🤖 This is an automated response from Repo Assist.

    I can no longer reproduce this on current main, including with a deliberately constrained stack.

    Tested commit daacf37b690df6a5edb053ec15581d6d34b9c3c5 (committed 2026-10-14 12:03 UTC, about 13 hours before this test). I copied the issue's complete 37-property/37-do! Chiron script unchanged into issue13084.fsx, added only printfn "TYPECHECK_OK", and ran:

    ./.dotnet/dotnet artifacts/bin/fsi/Release/net11.0/fsi.dll --readline- --exec issue13084.fsx
    TYPECHECK_OK
    
    (ulimit -s 1024; ./.dotnet/dotnet artifacts/bin/fsi/Release/net11.0/fsi.dll --readline- --exec issue13084.fsx)
    TYPECHECK_OK

    The second run limits the process stack to 1 MiB and still completes without FSHARP_TcStackGuardDepth or COMPlus_DefaultStackSize. The compiler now checks available stack with RuntimeHelpers.TryEnsureSufficientExecutionStack() and moves recursive work to a fresh thread when needed, which directly addresses the platform-dependent failure mode reported here.

    Compiler identity from the built artifact (#version;;):

    Microsoft (R) F# Interactive version 15.2.200.0 for F# 11.2
    Language Version: 11.2
    FSharp.Core: 11.0.0.0
    .NET: .NET 11.0.0-rc.1.26420.103
    OS: Linux 6.17.0-1022-azure (X64)
    

    Given the exact repro succeeds even under a much smaller stack, I applied AI-thinks-issue-fixed.

    Warning

    Firewall blocked 1 domain

    The following domain was blocked by the firewall during workflow execution:

    • southcentralus0.in.applicationinsights.azure.com

    To allow these domains, add them to the network.allowed list in your workflow frontmatter:

    network:
      allowed:
        - defaults
        - "southcentralus0.in.applicationinsights.azure.com"

    See Network Configuration for more information.

    Generated by 🌈 Repo Assist, see workflow run. Learn more.

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@7c7feb61a52b662eb2089aa2945588b7a200d404
    
  13. added a commit that references this issue on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    AI-thinks-issue-fixedArea-Compiler-CheckingBugImpact-Medium

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions