Skip to content

FSC.exe StackOverflow when building in release (Optimize = true) #10443

@kowalgta

Description

@kowalgta

This bug showed up after I've upgraded one of our internal services to .NET Framework 4.8 (from 4.6.2). It happens only in release mode (or when optimize flag is set to true).

Codebase worked fine when it was targeting .NET Framework 4.6.2 (that was compiled using fsc.exe located at C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0 and of version 14.0.23413.0). Once I upgraded it to 4.8 msbuild started compiling it with latest FSC.exe version in the system (located at C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\FSharp - 11.0.0.0 for F# 5.0. It was also happening when compiling using the latest .NET Core 3.1 SDK)

An application that suffered from this problem is a Suave service that returns Json data formated using Chiron. I suspect that it has something to do with the fact that Chiron enforces ToJson / FromJson members on the types that one wants to serialise to Json. As it's all done using statically resolved type parameters it can result in excessive inlining?

I've carved out the original solution to the step when it just fails. If it's simplified a bit more it will compile. For example:

Please note that the naming and structure is not from the original codebase.

I would be happy to try to debug it further but frankly have no idea where to start?

Repro steps

  1. Clone https://github.com/kowalgta/FSCStackoverflowBug
  2. Run build (or from Visual Studio in Release mode)

Expected behavior

It should compile.

Actual behavior

Compiler crashes after a few seconds with code -1073741571.

Known workarounds

Set compiler optimize flag to false.

Related information

  • Windows 10 (10.0.19042 Build 19042)
  • .NET Core 3.1.403 or .NET 5.0
  • Visual Studio

Metadata

Metadata

Assignees

Labels

BugImpact-High(Internal MS Team use only) Describes an issue with extreme impact on existing code.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions