Skip to content

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 17, 2021

Backport of #59220 to release/6.0-rc2

/cc @lambdageek

Customer Impact

Interpreted .NET 6 Android applications that depend on AndroidX, Maui, SkiaSharp and other frameworks crash at startup.

When a project references some of these frameworks, the build process generates a method that initializes C# fields corresponding to Android resources. This method can be very large and it can initialize on the order of ~100k fields. This stresses a limit in the interpreter on the number of data items that a single method can mention.

Testing

CI and manual testing.

Risk

Low.

The issue does not arise in the mono JIT or in AOT. While developers would lose out on the ability to use hot reload with their code, disabling the interpreter is a viable workaround.

The fix adds a new interpreter opcode that raises the limit on the number of data items that can be referenced from 64k to 4 billion. The fix is tailored to the particular generated UpdateIdValues method from .NET 6 Android. It does not address more general limitations of interpreting large method bodies.

lambdageek and others added 9 commits September 17, 2021 13:05
For methods that require more than 64k data items, add a variant stsfld
instruction that stores data item indices as 32-bit integers instead of 16-bit.

To solve this problem in general, we need wide variants of more opcodes, but
for specific (machine generated) methods, a wide stsfld instruction is sufficient.

Resolves https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1398069
Use stackval_from_data and stackval_to_data instead of memcpy.

Don't duplicate code get_data_item_wide_index.

Only use the wide opcodes if any of the data item indices of a given
instruction need it, not just when the method total number of indices
overflows.
@ghost
Copy link

ghost commented Sep 17, 2021

Tagging subscribers to this area: @BrzVlad
See info in area-owners.md if you want to be subscribed.

Issue Details

Backport of #59220 to release/6.0-rc2

/cc @lambdageek

Customer Impact

Testing

Risk

Author: github-actions[bot]
Assignees: -
Labels:

area-Codegen-Interpreter-mono

Milestone: -

@lewing lewing added the Servicing-consider Issue for next servicing release review label Sep 17, 2021
@jamshedd jamshedd added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Sep 21, 2021
@steveisok steveisok merged commit 4689875 into release/6.0-rc2 Sep 21, 2021
@steveisok steveisok deleted the backport/pr-59220-to-release/6.0-rc2 branch September 21, 2021 20:45
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants