Skip to content

Fix g_gc_lowest_address updating#131324

Open
janvorli wants to merge 1 commit into
dotnet:mainfrom
janvorli:fix-gc-lowest-address-updating
Open

Fix g_gc_lowest_address updating#131324
janvorli wants to merge 1 commit into
dotnet:mainfrom
janvorli:fix-gc-lowest-address-updating

Conversation

@janvorli

Copy link
Copy Markdown
Member

There is a rare issue that occurs when virtual memory blocks allocated by GC end up getting addresses that trigger a code path where the g_gc_lowest_address .. g_gc_highest_address is expanded down and the g_gc_lowest_address is exactly 1/2 of the g_gc_highest_address. We end up setting the g_gc_lowest_address to 0 and that then breaks GC because it starts considering NULL references as being part of the GC heap.
The culprit is a check that uses > instead of >=, which prevents the g_gc_lowest_address to be clamped to OS_PAGE_SIZE as its minimal value.

Close #131216

There is a rare issue that occurs when virtual memory blocks allocated by GC
end up getting addresses that trigger a code path where the
`g_gc_lowest_address` .. `g_gc_highest_address` is expanded down and the
`g_gc_lowest_address` is exactly 1/2 of the `g_gc_highest_address`.
We end up setting the `g_gc_lowest_address` to 0 and that then breaks GC
because it starts considering NULL references as being part of the GC
heap.
The culprit is a check that uses `>` instead of `>=`, which prevents the
`g_gc_lowest_address` to be clamped to OS_PAGE_SIZE as its minimal
value.

Close dotnet#131216
@janvorli janvorli added this to the 11.0.0 milestone Jul 24, 2026
@janvorli
janvorli requested a review from kkokosa July 24, 2026 15:35
@janvorli janvorli self-assigned this Jul 24, 2026
Copilot AI review requested due to automatic review settings July 24, 2026 15:35
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @anicka-net, @dotnet/gc
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an edge-case in CoreCLR GC card-table growth logic where expanding the tracked heap address range could incorrectly allow g_gc_lowest_address to become 0, which can cause GC to treat null references as in-heap.

Changes:

  • Adjusts a boundary comparison from > to >= when deciding whether to clamp the new lowest address to OS_PAGE_SIZE, preventing the “exactly half” span case from underflowing to 0.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET Crash in GC code on ARM64 macOS

2 participants