Repository navigation
Description
Description
On .NET 10.0.13, workstation region GC can terminate a safe managed program
with Internal CLR error. (0x80131506) and exit 0xC0000005 when a small
heap hard limit is combined with DOTNET_gcConcurrent=0. CDB catches a
first-chance write AV in WKS::gc_heap::init_heap_segment on a reserved,
uncommitted page of CoreCLR's segment mapping table. .NET 11 RC2 has a
one-line alignment change that covers the omitted page. Please consider a
.NET 10 servicing backport.
Reproduction Steps
Create a net10.0 console project and use this Program.cs:
using var clock = new CancellationTokenSource();
var held = new byte[28][];
for (var i = 0; i < held.Length; i++) held[i] = new byte[1024 * 1024];
try
{
while (true)
{
_ = Task.Delay(Timeout.InfiniteTimeSpan, clock.Token);
var temporary = new byte[64 * 1024];
GC.KeepAlive(temporary);
}
}
catch (OutOfMemoryException)
{
Console.WriteLine("managed OOM");
}
GC.KeepAlive(held);In PowerShell with .NET 10 SDK and runtime 10.0.13 installed, build before
setting the heap limit:
dotnet new console --framework net10.0 --name GcHardLimitRepro
cd GcHardLimitRepro
# Replace Program.cs with the code above.
dotnet build -c Release
$env:DOTNET_GCHeapHardLimit = '2000000' # hexadecimal 32 MiB
$env:DOTNET_gcConcurrent = '0'
Remove-Item Env:DOTNET_GCPath,Env:DOTNET_GCName -ErrorAction SilentlyContinue
dotnet exec --fx-version 10.0.13 .\bin\Release\net10.0\GcHardLimitRepro.dllExpected behavior
The loop catches OutOfMemoryException, prints managed OOM, and exits
normally.
Actual behavior
The Release build terminated 3/3 times on .NET 10.0.13:
Fatal error.
Internal CLR error. (0x80131506)
at Program.<Main>$(System.String[])
exit=0xC0000005
CDB with matching coreclr.pdb stopped at the first-chance AV:
coreclr!WKS::gc_heap::init_heap_segment+0x63:
mov qword ptr [rcx+40h],rax
ExceptionCode: c0000005 (Access violation)
Parameter[0]: 0000000000000001 (write)
Parameter[1]: 0000027941298010
rcx=0000027941297fd0
!vprot @rcx MEM_COMMIT, PAGE_READWRITE, AllocationBase 0000027941270000
!vprot @rcx+40 MEM_RESERVE, AllocationBase 0000027941270000
The symbolized k/kv stack begins init_heap_segment →
make_heap_segment → allocate_new_region → get_free_region → SOH
allocation → GCHeap::Alloc → managed array allocation. The fault is a
write to a high, non-null address in the GC bookkeeping reservation.
Regression?
.NET 10.0.11 and 10.0.13 reproduce. The same Release binary returned caught
managed OOM 3/3 times on .NET 11.0.0-rc.2.26504.105 at 32 MiB limit /
28 MiB held. Earlier versions and the first build containing the fix were
not determined.
Known Workarounds
On .NET 10.0.13, enabling concurrent GC or selecting its standalone
clrgc.dll returned managed OOM in 3/3 controls each at 32/28 MiB. A
33 MiB limit with 28 MiB held also returned managed OOM 3/3.
Configuration
Windows 10.0.26300.0, x64, workstation region GC; .NET 10.0.13 CoreCLR
file version 10.0.1326.50504, VMR commit 4099f83977f4; SDK 10.0.400.
The comparison runtime is .NET 11 RC2 11.0.0-rc.2.26504.105, VMR commit
820230c386db. The failing configuration uses
DOTNET_GCHeapHardLimit=2000000 (hexadecimal 32 MiB),
DOTNET_gcConcurrent=0, and no standalone GC override.
Other information
Both versions size the mark array only when concurrent GC is enabled
(.NET 10 gc.cpp:9268-9273,
.NET 11 card_table.cpp:181-186)
and specify OS_PAGE_SIZE alignment for it (.NET 10 gc.cpp:9300,
.NET 11 card_table.cpp:213).
The layout guard differs:
// .NET 10 gc.cpp:9311
if ((element != total_bookkeeping_elements) && (sizes[element] != 0))
// .NET 11 card_table.cpp:224
if (element != total_bookkeeping_elements).NET 10 source ·
.NET 11 source.
With concurrent GC off, the zero sized mark array loses its page alignment
only in .NET 10. Both versions still cap the preceding segment mapping
commit at the lower page boundary of the next element
(.NET 10 gc.cpp:9468,
.NET 11 card_table.cpp:381).
The region mapping and initialization path is equivalent
(.NET 10 gc.cpp:12456,12492,
.NET 11 regions_segments.cpp:1218,1254).
In the CDB stop, the segment mapping table needed bookkeeping offsets
0x270b8 through 0x289a8, but the commit cap rounded the following
element's offset 0x28a50 down to 0x28000. The faulting field was at
0x28010. The .NET 11 condition aligns the next element to 0x29000.
Proposed one-line .NET 10 backport:
--- a/src/runtime/src/coreclr/gc/gc.cpp
+++ b/src/runtime/src/coreclr/gc/gc.cpp
@@ -9311 +9311 @@
- if ((element != total_bookkeeping_elements) && (sizes[element] != 0))
+ if (element != total_bookkeeping_elements)Untested: no rebuilt CoreCLR.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
dotnet-policy-service commentedon Oct 21, 2026
Tagging subscribers to this area: @anicka-net, @dotnet/gc
See info in area-owners.md if you want to be subscribed.
MihuBot commentedon Oct 21, 2026
I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):
[release/10.0] Fix AV in gc_heap::init_heap_segment (#136254)