Skip to content

Commit 54d40cf

Browse files
[release/9.0-staging] [mono][sgen] Add option to disable tarjan gc bridge optimization (#121376)
Backport of #121243 to release/9.0-staging /cc @BrzVlad ## Customer Impact - [x] Customer reported - [ ] Found internally Applications on maui-android can randomly crash during GC. We've had a few fixes for the tarjan bridge merged a few months ago, but there is still one more issue. The problem is caused by a specific optimization inside the tarjan gc bridge. The only workaround for a customer hitting this failure is to configure an environment variable so that their app uses a different gc bridge (which has worse performance). One customer reported that using the older gc bridge makes the application unusable due to degradation of performance. This PR allows users to opt out of a smaller optimization and keep using the tarjan gc bridge, as a workaround for .NET9. ## Regression - [ ] Yes - [x] No ## Testing Tested on our own gc bridge tests, with scenario causing the issue. ## Risk This PR has zero risk since it just adds support for disabling an optimization. By default, there is no change in behavior. I plan to backport to .NET10 the actual fix for this issue. --------- Co-authored-by: Vlad Brezae <[email protected]>
1 parent fe1f52e commit 54d40cf

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/mono/mono/metadata/sgen-bridge.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,8 @@ sgen_bridge_handle_gc_param (const char *opt)
687687

688688
if (!strcmp (opt, "bridge-require-precise-merge")) {
689689
bridge_processor_config.scc_precise_merge = TRUE;
690+
} else if (!strcmp (opt, "disable-non-bridge-scc")) {
691+
bridge_processor_config.disable_non_bridge_scc = TRUE;
690692
} else {
691693
return FALSE;
692694
}

src/mono/mono/metadata/sgen-tarjan-bridge.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,9 +976,9 @@ dump_color_table (const char *why, gboolean do_index)
976976
int i = 0, j;
977977
printf ("colors%s:\n", why);
978978

979-
for (cur = root_color_bucket; cur; cur = cur->next, ++i) {
979+
for (cur = root_color_bucket; cur; cur = cur->next) {
980980
ColorData *cd;
981-
for (cd = &cur->data [0]; cd < cur->next_data; ++cd) {
981+
for (cd = &cur->data [0]; cd < cur->next_data; ++cd, ++i) {
982982
if (do_index)
983983
printf ("\t%d(%d):", i, cd->api_index);
984984
else

0 commit comments

Comments
 (0)