-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
Recent versions (API 30 x86_64) of the Android emultator can run arm64 binaries on an x86_64 emultator using some kind of binary translation. When an app is running in this environment, it looks like the struct sigcontext
__reserved
field is not laid out with the fpsimd_context
first.
As a result this code asserts:
runtime/src/mono/mono/utils/mono-context.c
Lines 536 to 539 in b1b7ad4
struct fpsimd_context *fpctx = (struct fpsimd_context*)&((ucontext_t*)sigctx)->uc_mcontext.__reserved; | |
int i; | |
g_assert (fpctx->head.magic == FPSIMD_MAGIC); |
Linux kernel sigcontext
__reserved
note
Instead of looking at the first context in __reserved
and asserting that it has FPSIMD_MAGIC
, we should check head.magic == FPSIMD_MAGIC
and if not, move forward by head.size
bytes and try again until we see head.magic == 0
(the last block).
Potentially we can assume that the offset won't change between calls to mono_sigctx_to_monoctx
and cache the pre-computed offset (and assert that the magic is the right one).
Reproduction steps for XA:
- Turn off fast deployment by adding
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
to the csproj file - Remove definition for
$(AndroidSupportedAbis)
if there is any in the .csproj file - Add
<RuntimeIdentifiers>android-arm;android-arm64</RuntimeIdentifiers>
to the csproj file - Build and run the app in Release mode on x86_64 emulator crashes using
dotnet build -c Release -t:Run