[release/9.0-staging][mono][gc] Fix gc descriptor computation for InlineArray structs #116951
+6
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
compute_class_bitmap
iterates over all ref field slots in the current class so we can produce a GC descriptor.field_iter
represents how many times the type in question is repeated in the current struct. Instead of bumping the current offset by the size of the repeated field, for each iteration, we were addingfield_offset
which is wrong.Customer Impact
Types having
InlineArray
attribute are not correctly scanned by the GC for refs. This can lead to GC crashes on Maui applications. User reported problem migrating from legacy xamarin to maui Humanizr/Humanizer#1572.Regression
InlineArray
attribute for types was added around .NET8, with some uses showing up in the libraries code in .NET9, which could lead to regressions for some users.Testing
Tested on local test that the GC descriptor is now computed correctly for types with
InlineArray
attribute. Verified fix on sample app provided by customer.Risk
Low. The fix is localized to types that have
InlineArray
attribute, where the previous implementation was completely broken.