Skip to content

[release/10.0] [mono][sgen] Fix card scanning in LOS non-array objects#125213

Open
github-actions[bot] wants to merge 1 commit intorelease/10.0from
backport/pr-125116-to-release/10.0
Open

[release/10.0] [mono][sgen] Fix card scanning in LOS non-array objects#125213
github-actions[bot] wants to merge 1 commit intorelease/10.0from
backport/pr-125116-to-release/10.0

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 5, 2026

Backport of #125116 to release/10.0

/cc @BrzVlad

Customer Impact

  • Customer reported
  • Found internally

In some cases, cards marked for non-array LOS objects (objects with size greater than 8K) were being ignored. This means that the GC could fail to observe that some object refs were stored inside these large objects. This can result in GC crashes or other undefined behavior. This can impact all mono workloads. This issue was confirmed to be hit by a customer who also investigated it via a GC debug flag. There are other undiagnosed GC crashes that might hopefully be fixed by this.

Regression

  • Yes
  • No

Testing

Was able to create a console app reproducing this bug. Validated the fix.

Risk

Low. The fix just does an address alignment, in order to scan correctly an additional card.

`sgen_card_table_region_begin_scanning` needs to determine whether any cards are marked in the object starting at `start` address. The current card size in 512 bytes. Consider an object with start 500 and size 20, so this object lives within 2 cards. We will check the card associated with the address 500. Once this iteration is done, we will check whether  `start + card_size < end` => `500 + 512 < 520`. This is false, so we will no longer scan the second card. The algorithm was expecting the start address to be aligned to the card start, which is what the fix does.

This bug is severe, but, in practice, this code path is not as frequent. This bug would only affect objects greater than 8k, that are not arrays.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-VM-meta-mono Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant