Skip to content

Android AOT startup crash  #102166

@kerams

Description

@kerams

Description

Avalonia application for Android compiled with AOT and 9.0.0-preview.3.24172.9 crashes on an Android 10 ARM64 device, but not in x64 emulator.

Reproduction Steps

It's a closed source application, but I'm almsot willing to bet it could be reproduced with a minimal Avalonia template. In any case, here are the fsproj settings:

Details
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net9.0-android</TargetFramework>
    <SupportedOSPlatformVersion>26.0</SupportedOSPlatformVersion>
    <AndroidPackageFormat>apk</AndroidPackageFormat>
    <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)'=='Release'">
    <PublishTrimmed>true</PublishTrimmed>
    <TrimMode>partial</TrimMode>
    <RunAOTCompilation>True</RunAOTCompilation>
    <AndroidKeyStore>False</AndroidKeyStore>
    <AndroidLinkTool>r8</AndroidLinkTool>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)'=='Debug'">
    <AndroidKeyStore>False</AndroidKeyStore>
  </PropertyGroup>
  <Target Name="ConfigureTrimming" BeforeTargets="PrepareForILLink">
    <ItemGroup>
      <ManagedAssemblyToLink Condition="'%(Filename)' == 'System.Private.CoreLib'">
        <IsTrimmable>false</IsTrimmable>
      </ManagedAssemblyToLink>
    </ItemGroup>
  </Target>
  <ItemGroup>
    <None Include="Properties\AndroidManifest.xml" />
    <AndroidResource Include="Resources\**\*" />
    <Compile Include="MainActivity.fs" />
    <Compile Include="SplashActivity.fs" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Mobile.Common\Mobile.Common.fsproj" />
  </ItemGroup>
  <Import Project="..\..\..\.paket\Paket.Restore.targets" />
</Project>

Expected behavior

No startup crash.

Actual behavior

Startup crash with

05-13 20:34:25.189 20328 20328 I crash_dump64: performing dump of process 20295 (target tid = 20295)
05-13 20:34:25.203 20328 20328 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-13 20:34:25.203 20328 20328 F DEBUG   : LineageOS Version: '17.1-20200924-NIGHTLY-pioneer'
05-13 20:34:25.203 20328 20328 F DEBUG   : Build fingerprint: 'Sony/H3113/H3113:8.0.0/50.1.A.4.76/2209478692:user/release-keys'
05-13 20:34:25.203 20328 20328 F DEBUG   : Revision: '0'
05-13 20:34:25.203 20328 20328 F DEBUG   : ABI: 'arm64'
05-13 20:34:25.204 20328 20328 F DEBUG   : Timestamp: 2024-05-13 20:34:25+0200
05-13 20:34:25.204 20328 20328 F DEBUG   : pid: 20295, tid: 20295, name: com.snipperino  >>> com.snipperino <<<
05-13 20:34:25.204 20328 20328 F DEBUG   : uid: 10140
05-13 20:34:25.204 20328 20328 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x234
05-13 20:34:25.204 20328 20328 F DEBUG   : Cause: null pointer dereference
05-13 20:34:25.204 20328 20328 F DEBUG   :     x0  0000000000000000  x1  665f746f615f6f6e  x2  6f666e695f656c69  x3  0000000000000006
05-13 20:34:25.204 20328 20328 F DEBUG   :     x4  20434c4120640000  x5  0000007069ff6de0  x6  6f6e20646c756f43  x7  7320646e69662074
05-13 20:34:25.204 20328 20328 F DEBUG   :     x8  0000000000000234  x9  000000706e216b00  x10 0000000000000001  x11 0000007040000000
05-13 20:34:25.204 20328 20328 F DEBUG   :     x12 0000000000000060  x13 000000000b006518  x14 0000000000000060  x15 0000008000000000
05-13 20:34:25.204 20328 20328 F DEBUG   :     x16 000000715dd998f0  x17 000000715dd8bb50  x18 0000007161f9a000  x19 000000706dfea320
05-13 20:34:25.204 20328 20328 F DEBUG   :     x20 00000070cc142580  x21 0000007069f85a10  x22 0000007069d428e0  x23 0000000000000000
05-13 20:34:25.204 20328 20328 F DEBUG   :     x24 0000007069f859e0  x25 000000706dfea330  x26 0000007075c3dc81  x27 00000070cc5e2d24
05-13 20:34:25.204 20328 20328 F DEBUG   :     x28 0000007069f85a30  x29 0000007fef3929b0
05-13 20:34:25.204 20328 20328 F DEBUG   :     sp  0000007fef392920  lr  00000070cc41f198  pc  00000070cc41f1a4
05-13 20:34:25.205 20328 20328 F DEBUG   :
05-13 20:34:25.205 20328 20328 F DEBUG   : backtrace:
05-13 20:34:25.205 20328 20328 F DEBUG   :       #00 pc 00000000001361a4  /data/app/com.snipperino-a456wxPK2kFg2-Xouzh1dA==/lib/arm64/libmonosgen-2.0.so (BuildId: 2929beb5d26398447fb2d28409a70eccf684c59e)
05-13 20:34:25.205 20328 20328 F DEBUG   :       #01 pc 00000000001fbb08  /data/app/com.snipperino-a456wxPK2kFg2-Xouzh1dA==/lib/arm64/libmonosgen-2.0.so (BuildId: 2929beb5d26398447fb2d28409a70eccf684c59e)
05-13 20:34:25.205 20328 20328 F DEBUG   :       #02 pc 00000000001fc830  /data/app/com.snipperino-a456wxPK2kFg2-Xouzh1dA==/lib/arm64/libmonosgen-2.0.so (BuildId: 2929beb5d26398447fb2d28409a70eccf684c59e)
05-13 20:34:25.206 20328 20328 F DEBUG   :       #03 pc 00000000001fdd0c  /data/app/com.snipperino-a456wxPK2kFg2-Xouzh1dA==/lib/arm64/libmonosgen-2.0.so (mono_assembly_load_from_full+116) (BuildId: 2929beb5d26398447fb2d28409a70eccf684c59e)
05-13 20:34:25.206 20328 20328 F DEBUG   :       #04 pc 000000000001c060  /data/app/com.snipperino-a456wxPK2kFg2-Xouzh1dA==/lib/arm64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::open_from_bundles(void*, _MonoAssemblyName*, char**, void*, _MonoError*)+7028) (BuildId: 941d3c28803eb1b4b2fb9ecfdf447edfd0a21e95)

Detailed logcat output: logcat.zip

Regression?

Yes, application launches when compiled using 9.0.100-preview.2.24157.14

It's also slightly concerning that the output apk containing libraries for all 4 ABIs is 85MB on Preview 3 and 65MB on Preview 2.

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions