Skip to content

Fix wrong gc join in BGC mark phase#126389

Merged
janvorli merged 2 commits intodotnet:mainfrom
janvorli:fix-wrong-gc-join-bgc-mark
Apr 1, 2026
Merged

Fix wrong gc join in BGC mark phase#126389
janvorli merged 2 commits intodotnet:mainfrom
janvorli:fix-wrong-gc-join-bgc-mark

Conversation

@janvorli
Copy link
Copy Markdown
Member

@janvorli janvorli commented Apr 1, 2026

There was a wrong join struct instance being used in the background_mark_phase. Instead of bgc_t_join, it was using gc_t_join that is meant for regular mark phase usage. It caused hangs during GC in some edge cases, for example for GCPerfSim invocation with the following command line:
GCPerfSim.dll -tc 4 -tagb 540 -tlgb 0 -lohar 1000 -pohar 0 -sohsr 100-4000 -lohsr 102400-204800 -pohsr 100-204800 -sohsi 0 -lohsi 0 -pohsi 0 -sohpi 0 -lohpi 0 -sohfi 0 -lohfi 0 -pohfi 0 -allocType reference -testKind time

The issue was introduced by the change that added the JAVA GC bridge.

Close #122996

There was a wrong join struct instance being used in the
`background_mark_phase`. Instead of `bgc_t_join`, it was using `gc_t_join`
that is meant for regular mark phase usage. It caused hangs during GC in
some edge cases, for example for GCPerfSim invocation with the following
command line:
GCPerfSim.dll -tc 4 -tagb 540 -tlgb 0 -lohar 1000 -pohar 0 -sohsr 100-4000
-lohsr 102400-204800 -pohsr 100-204800 -sohsi 0 -lohsi 0 -pohsi 0 -sohpi 0
-lohpi 0 -sohfi 0 -lohfi 0 -pohfi 0 -allocType reference -testKind time

The issue was introduced by the change that added the JAVA GC bridge.

Close dotnet#122996
@janvorli janvorli added this to the 10.0.x milestone Apr 1, 2026
@janvorli janvorli requested a review from BrzVlad April 1, 2026 00:50
@janvorli janvorli self-assigned this Apr 1, 2026
Copilot AI review requested due to automatic review settings April 1, 2026 00:50
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a GC hang in gc_heap::background_mark_phase() by using the correct background-GC join structure for the Java GC bridge processing join/restart sequence, aligning BGC synchronization with the rest of background.cpp.

Changes:

  • Replace gc_t_join with bgc_t_join for the gc_join_bridge_processing barrier in background_mark_phase().
  • Ensure BGC threads are joined/restarted using the BGC-specific join instance during bridge object processing.

@mangod9
Copy link
Copy Markdown
Member

mangod9 commented Apr 1, 2026

Is this a regression in 10?

@BrzVlad
Copy link
Copy Markdown
Member

BrzVlad commented Apr 1, 2026

This is not really a regression since the gc bridge support was added on .net10. This code is under FEATURE_JAVAMARSHAL which is enabled only on android and debug builds. Still, backporting is reasonable to me.

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Apr 1, 2026

backporting is reasonable to me.

I do not see valid justification for a backport.

@BrzVlad
Copy link
Copy Markdown
Member

BrzVlad commented Apr 1, 2026

You are right. I didn't realize initially that this code is server gc only.

@janvorli janvorli merged commit 9d577cf into dotnet:main Apr 1, 2026
108 of 111 checks passed
@janvorli janvorli deleted the fix-wrong-gc-join-bgc-mark branch April 1, 2026 12:55
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.

Some parameters and GC modes block gcperfsim

5 participants