Description
Description
Calling GC.Collect()
when having sufficiently large objects in LOH and using the Server Garbage Collection causes Access Violation exception (cx0000005) being thrown from coreclr.dll
CoreCLR Version: 7.0.22.51805
.NET Version: 7.0.0
Description: The process was terminated due to an unhandled exception.
Exception Info: exception code c0000005
We have seen this on Windows 10 Enterprise
and on Windows Server 2016
Reproduction Steps
Code
open System
[<Struct>]
type T = {
A: DateTime
B: int
C: float
D: byte }
let data: T array = Array.zeroCreate 2_000_000_000
GC.Collect()
printfn "All OK"
Project file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
</Project>
Run this with dotnet run -c release
Changes that leads to program running OK
- Allocating with size
1_000_000_000
- Changing the order of
B
andC
in the struct
Expected behavior
The program writes All OK
to the console.
Actual behavior
The program crashes and we see in the Event log that The process was terminated due to an unhandled exception
with exception code c0000005
Regression?
We never saw this on NET 6, but it appeared immediately efter we upgraded to NET 7.
Known Workarounds
No response
Configuration
.NET version
CoreCLR Version: 7.0.22.51805
.NET Version: 7.0.0
OS
Edition Windows 10 Enterprise
Version 21H2
Installed on 03/10/2020
OS build 19044.2251
Experience Windows Feature Experience Pack 120.2212.4180.0
Architecture
x64
Other information
No response