Skip to content

[android] arm64 running on x64 emulator unexpected FPSIMD_MAGIC assert #62201

@lambdageek

Description

@lambdageek

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:

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:

  1. Turn off fast deployment by adding <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk> to the csproj file
  2. Remove definition for $(AndroidSupportedAbis) if there is any in the .csproj file
  3. Add <RuntimeIdentifiers>android-arm;android-arm64</RuntimeIdentifiers> to the csproj file
  4. Build and run the app in Release mode on x86_64 emulator crashes using dotnet build -c Release -t:Run

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions