Skip to content

[mono][sgen] Fix initialization of can_reduce_color #114637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2025

Conversation

BrzVlad
Copy link
Member

@BrzVlad BrzVlad commented Apr 14, 2025

Mark it as true also in the case when the SCC contains bridge objects. Code populating other_colors for this SCC depends on it.

Mark it as true also in the case when the SCC contains bridge objects. Code populating other_colors for this SCC depends on it.
@Copilot Copilot AI review requested due to automatic review settings April 14, 2025 17:18
@ghost ghost added the area-VM-meta-mono label Apr 14, 2025
Copy link
Contributor

@Copilot 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.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

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

  • Ensure that there are unit tests covering both cases: when SCCs contain xrefs and when they contain bridge objects without xrefs, to verify that can_reduce_color is set correctly.
if (dyn_array_ptr_size (&other->xrefs) > 0 || found_bridge) {

@BrzVlad
Copy link
Member Author

BrzVlad commented Apr 14, 2025

@filipnavara Vitek said that MAUI encountered this assertion after backport of #114391

Assertion at /w/1/s/src/mono/mono/metadata/sgen-tarjan-bridge.c:801, condition `can_reduce_color == FALSE' not met
      04-11 15:13:22.192  3831  3831 F monodroid: * Assertion at /w/1/s/src/mono/mono/metadata/sgen-tarjan-bridge.c:801, condition `can_reduce_color == FALSE' not met`

It looks like this could happen if the initial iteration over the loop stack encounters a bridge object early (so it doesn't set can_reduce_color to FALSE). Then, in the second iteration (after the node heaviness fix), we would assert when encountering a node with other->xrefs populated. cc @vitek-karas @jeffschwMSFT

The test is meant to be run only on desktop.
@filipnavara
Copy link
Member

filipnavara commented Apr 14, 2025

Right, this is the correct fix, or changing the assert to g_assert (can_reduce_color == FALSE || found_bridge);.

Thanks!

@BrzVlad
Copy link
Member Author

BrzVlad commented Apr 14, 2025

Added a new commit to disable running the test on wasm and mobile. Seems like on 9.0 runs it was failing, although no failures were spotted on main.

@BrzVlad BrzVlad merged commit 46dddf1 into dotnet:main Apr 15, 2025
113 of 118 checks passed
filipnavara pushed a commit to filipnavara/runtime that referenced this pull request Apr 15, 2025
* [mono][sgen] Fix initialization of can_reduce_color

Mark it as true also in the case when the SCC contains bridge objects. Code populating other_colors for this SCC depends on it.

* Disable test on wasm and mobile

The test is meant to be run only on desktop.
@github-actions github-actions bot locked and limited conversation to collaborators May 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants