Skip to content

64-bit fscAnyCpu.exe uses more stack than 32-bit fsc.exe (was: Project that builds in VS2019 fails to build in VS2022) #12322

Description

@kentcb

A project that is part of a reasonably complex solution is failing to build in 2022 due to the compiler crashing. I've managed to boil things down to a simple, standalone repro shown below.

Repro steps

The following simplified code typifies that which is causing the compiler to crash:

module repro_fscanycpu_failure

//
// This builds fine in VS2019, but fails under VS2022 with:
//
// 1>  Process is terminated due to StackOverflowException.
// 1>  C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools\Microsoft.FSharp.Targets(317,9): error MSB6006: "fscAnyCpu.exe" exited with code -1073741571.
//
// Opening this file in the VS2022 editor will also crash, presumably for the same underlying reason.
//

type ReproBuilder () =
    member _.Delay x = x ()
    member _.Yield  (x) = x
    member _.Combine (x, y) = x + y

let repro = ReproBuilder ()

let callSite () =
    repro {
        // Commenting out some of the below is enough to avoid StackOverflow on my machine.
        0
        1
        2
        3
        4
        5
        6
        7
        8
        9
        0
        1
        2
        3
        4
        5
        6
        7
        8
        9
        0
        1
        2
        3
        4
        5
        6
        7
        8
        9
        0
        1
        2
        3
        4
        5
        6
        7
        8
        9
        0
        1
        2
        3
        4
    }

Expected behavior

It should build in 2022 as it does in 2019.

Actual behavior

It fails with:

1>C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools\Microsoft.FSharp.Targets(317,9): error MSB6006: "fscAnyCpu.exe" exited with code -1073741571.

Known workarounds

  1. Short-term fix: Use VS2019.

  2. Recommended: Make your inputs smaller, probably half the size will do, divide your large expressions into two

Related information

Provide any related information (optional):

  • Windows 10
  • .NET Core

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions