dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.56k stars 4.54k forks source link

[Android] Crash on startup after enabling LLVM #104163

Open mfeingol opened 3 weeks ago

mfeingol commented 3 weeks ago

Description

tldr my release build works fine but when I enable LLVM it crashes on startup.

Might relate to https://github.com/dotnet/runtime/issues/95406

Time    Device Name Type    PID Tag Message
    pixel_7_pro_-_api_34    Error   6723    DEBUG   backtrace:
      #00 pc 0000000000061610  /apex/com.android.runtime/lib64/bionic/libc.so (abort+192) (BuildId: fa337969c798946280caa45e2d71a2e7)
      dotnet/maui#1 pc 000000000001ff35  /data/app/~~iE2bxvuap7ttxEft6HbA_g==/com.Backroads.Android-jtTIQdF1fgsCPG8uWdEM4Q==/split_config.x86_64.apk!libmono-android.release.so (offset 0x207b000) (xamarin::android::Helpers::abort_application()+5) (BuildId: 226924acabe562f9a9a6034a03319acbb1de8db7)
      dotnet/maui#2 pc 0000000000039a79  /data/app/~~iE2bxvuap7ttxEft6HbA_g==/com.Backroads.Android-jtTIQdF1fgsCPG8uWdEM4Q==/split_config.x86_64.apk!libmono-android.release.so (offset 0x207b000) (xamarin::android::internal::MonodroidRuntime::mono_log_handler(char const*, char const*, char const*, int, void*)+105) (BuildId: 226924acabe562f9a9a6034a03319acbb1de8db7)
      dotnet/maui#3 pc 000000000021fb7a  /data/app/~~iE2bxvuap7ttxEft6HbA_g==/com.Backroads.Android-jtTIQdF1fgsCPG8uWdEM4Q==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x20cc000) (BuildId: be38e813fcbccfbfaf695f8a77eba641b0bee3d7)
      dotnet/maui#4 pc 000000000021fd04  /data/app/~~iE2bxvuap7ttxEft6HbA_g==/com.Backroads.Android-jtTIQdF1fgsCPG8uWdEM4Q==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x20cc000) (BuildId: be38e813fcbccfbfaf695f8a77eba641b0bee3d7)
      dotnet/maui#5 pc 000000000021fd46  /data/app/~~iE2bxvuap7ttxEft6HbA_g==/com.Backroads.Android-jtTIQdF1fgsCPG8uWdEM4Q==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x20cc000) (BuildId: be38e813fcbccfbfaf695f8a77eba641b0bee3d7)
      dotnet/maui#6 pc 0000000000167cc6  /data/app/~~iE2bxvuap7ttxEft6HbA_g==/com.Backroads.Android-jtTIQdF1fgsCPG8uWdEM4Q==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x20cc000) (BuildId: be38e813fcbccfbfaf695f8a77eba641b0bee3d7)
      dotnet/maui#7 pc 000000000017dae0  /data/app/~~iE2bxvuap7ttxEft6HbA_g==/com.Backroads.Android-jtTIQdF1fgsCPG8uWdEM4Q==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x20cc000) (BuildId: be38e813fcbccfbfaf695f8a77eba641b0bee3d7)
      dotnet/maui#8 pc 0000000000000d95  <anonymous:41003000>

Steps to Reproduce

This seems to do it:

  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android34.0|AnyCPU'">
    <RunAOTCompilation>true</RunAOTCompilation>
    <AndroidLinkResources>true</AndroidLinkResources>
    <EnableLLVM>true</EnableLLVM>
  </PropertyGroup>

Link to public reproduction project repository

No response

Version with bug

8.0.40 SR5

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 14

Did you find any workaround?

Don't use LLVM

Relevant log output

Time    Device Name Type    PID Tag Message
    pixel_7_pro_-_api_34    Error   210 tombstoned  Tombstone written to: tombstone_09
    pixel_7_pro_-_api_34    Error   6723    DEBUG   backtrace:
      #00 pc 0000000000061610  /apex/com.android.runtime/lib64/bionic/libc.so (abort+192) (BuildId: fa337969c798946280caa45e2d71a2e7)
      dotnet/maui#1 pc 000000000001ff35  /data/app/~~iE2bxvuap7ttxEft6HbA_g==/com.Backroads.Android-jtTIQdF1fgsCPG8uWdEM4Q==/split_config.x86_64.apk!libmono-android.release.so (offset 0x207b000) (xamarin::android::Helpers::abort_application()+5) (BuildId: 226924acabe562f9a9a6034a03319acbb1de8db7)
      dotnet/maui#2 pc 0000000000039a79  /data/app/~~iE2bxvuap7ttxEft6HbA_g==/com.Backroads.Android-jtTIQdF1fgsCPG8uWdEM4Q==/split_config.x86_64.apk!libmono-android.release.so (offset 0x207b000) (xamarin::android::internal::MonodroidRuntime::mono_log_handler(char const*, char const*, char const*, int, void*)+105) (BuildId: 226924acabe562f9a9a6034a03319acbb1de8db7)
      dotnet/maui#3 pc 000000000021fb7a  /data/app/~~iE2bxvuap7ttxEft6HbA_g==/com.Backroads.Android-jtTIQdF1fgsCPG8uWdEM4Q==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x20cc000) (BuildId: be38e813fcbccfbfaf695f8a77eba641b0bee3d7)
      dotnet/maui#4 pc 000000000021fd04  /data/app/~~iE2bxvuap7ttxEft6HbA_g==/com.Backroads.Android-jtTIQdF1fgsCPG8uWdEM4Q==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x20cc000) (BuildId: be38e813fcbccfbfaf695f8a77eba641b0bee3d7)
      dotnet/maui#5 pc 000000000021fd46  /data/app/~~iE2bxvuap7ttxEft6HbA_g==/com.Backroads.Android-jtTIQdF1fgsCPG8uWdEM4Q==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x20cc000) (BuildId: be38e813fcbccfbfaf695f8a77eba641b0bee3d7)
      dotnet/maui#6 pc 0000000000167cc6  /data/app/~~iE2bxvuap7ttxEft6HbA_g==/com.Backroads.Android-jtTIQdF1fgsCPG8uWdEM4Q==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x20cc000) (BuildId: be38e813fcbccfbfaf695f8a77eba641b0bee3d7)
      dotnet/maui#7 pc 000000000017dae0  /data/app/~~iE2bxvuap7ttxEft6HbA_g==/com.Backroads.Android-jtTIQdF1fgsCPG8uWdEM4Q==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x20cc000) (BuildId: be38e813fcbccfbfaf695f8a77eba641b0bee3d7)
      dotnet/maui#8 pc 0000000000000d95  <anonymous:41003000>
    pixel_7_pro_-_api_34    Error   6723    DEBUG   9 total frames
    pixel_7_pro_-_api_34    Error   6723    DEBUG   signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
    rax 0000000000000000  rbx 00007ef2f179dcc8  rcx 00007ef2f5ac7610  rdx 0000000000000006
    r8  00007ef1a85713d1  r9  00007ef1a85713d1  r10 00007ef2f179dcd0  r11 0000000000000203
    r12 00007ef13855e160  r13 00007eefed797a58  r14 0000000000001a0b  r15 0000000000001a25
    rdi 0000000000001a0b  rsi 0000000000001a25
    rbp 0000000000000004  rsp 00007ef2f179dcc0  rip 00007ef2f5ac7610
    pixel_7_pro_-_api_34    Error   6723    DEBUG   uid: 10193
    pixel_7_pro_-_api_34    Error   6723    DEBUG   pid: 6667, tid: 6693, name: .NET TP Gate  >>> com.Backroads.Android <<<
    pixel_7_pro_-_api_34    Error   6723    DEBUG   Cmdline: com.Backroads.Android
    pixel_7_pro_-_api_34    Error   6723    DEBUG   Process uptime: 3s
    pixel_7_pro_-_api_34    Error   6723    DEBUG   Timestamp: 2024-06-13 17:41:40.211058300-0600
    pixel_7_pro_-_api_34    Error   6723    DEBUG   ABI: 'x86_64'
    pixel_7_pro_-_api_34    Error   6723    DEBUG   Revision: '0'
    pixel_7_pro_-_api_34    Error   6723    DEBUG   Build fingerprint: 'google/sdk_gphone64_x86_64/emu64xa:14/UE1A.230829.036.A2/11596452:userdebug/dev-keys'
    pixel_7_pro_-_api_34    Error   6723    DEBUG   *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    pixel_7_pro_-_api_34    Info    0   logd    logdr: UID=10193 GID=10193 PID=6723 n tail=500 logMask=1 pid=6667 start=0ns deadline=0ns
    pixel_7_pro_-_api_34    Error   6667    OpenGLRenderer  Unable to match the desired swap behavior.
    pixel_7_pro_-_api_34    Info    0   logd    logdr: UID=10193 GID=10193 PID=6723 n tail=500 logMask=8 pid=6667 start=0ns deadline=0ns
    pixel_7_pro_-_api_34    Info    0   servicemanager  Could not find android.hardware.graphics.allocator.IAllocator/default in the VINTF manifest.
    pixel_7_pro_-_api_34    Info    6667    Gralloc4    mapper 4.x is not supported
    pixel_7_pro_-_api_34    Info    158 hwservicemanager    getTransport: Cannot find entry android.hardware.graphics.mapper@4.0::IMapper/default in either framework or device VINTF manifest.
    pixel_7_pro_-_api_34    Warning 6667    OpenGLRenderer  Failed to initialize 101010-2 format, error = EGL_SUCCESS
    pixel_7_pro_-_api_34    Warning 6667    OpenGLRenderer  Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
    pixel_7_pro_-_api_34    Debug   555 CoreBackPreview Window{e24b62b u0 com.Backroads.Android/crc6446b5211041beaccb.MainActivity}: Setting back callback OnBackInvokedCallbackInfo{mCallback=android.window.IOnBackInvokedCallback$Stub$Proxy@fbf8846, mPriority=0, mIsAnimationCallback=false}
    pixel_7_pro_-_api_34    Info    6667    Choreographer   Skipped 130 frames!  The application may be doing too much work on its main thread.
    pixel_7_pro_-_api_34    Warning 6667    OpenGLRenderer  Unknown dataspace 0
    pixel_7_pro_-_api_34    Debug   6667    CompatibilityChangeReporter Compat change id reported: 237531167; UID 10193; state: DISABLED
    pixel_7_pro_-_api_34    Info    6723    crash_dump64    performing dump of process 6667 (target tid = 6693)
    pixel_7_pro_-_api_34    Info    210 tombstoned  received crash request for pid 6693
    pixel_7_pro_-_api_34    Info    6723    crash_dump64    obtaining output fd from tombstoned, type: kDebuggerdTombstoneProto
    pixel_7_pro_-_api_34    Info    6667    ckroads.Android Explicit concurrent copying GC freed 35096(2346KB) AllocSpace objects, 9(308KB) LOS objects, 49% free, 3448KB/6896KB, paused 4.672ms,39us total 13.355ms
    pixel_7_pro_-_api_34    Error   6667    libc    Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 6693 (.NET TP Gate), pid 6667 (ckroads.Android)
    pixel_7_pro_-_api_34    Error   6667    ckroads.Android * Assertion at /__w/1/s/src/mono/mono/mini/aot-runtime.c:5220, condition `plt_entry' not met
    pixel_7_pro_-_api_34    Error   6667    ckroads.Android * Assertion at /__w/1/s/src/mono/mono/mini/aot-runtime.c:5220, condition `plt_entry' not met
github-actions[bot] commented 3 weeks ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

drasticactions commented 3 weeks ago

Does this happen specifically within your app? Does it happen with a new MAUI UI Template app? Does it happen on a dotnet Android (dotnet new android) app that doesn't use MAUI UI?

mfeingol commented 2 weeks ago

@drasticactions: clean new sample app seems to work with LLVM enabled.

ninachen03 commented 2 weeks ago

Verified this original issue with Visual Studio 17.11.0 Preview 2.0 (8.0.60 & 8.0.3 ). Cannot repro it on android

mfeingol commented 2 weeks ago

I installed VS 17.11.0 Preview 2.0. Was able to repro with 8.0.60. Attempted to install 9.0.0-preview.5.24307.10 and had a bunch of unresolved resources and namespaces when compiling for Android... which I didn't have time to work through so I gave up on that.

tldr, it still repros with the latest VS preview.

PureWeen commented 1 week ago

@jonathanpeppers any thoughts?

jonathanpeppers commented 1 week ago

I think we can move this to runtime.

@mfeingol you might see if you can get a more detailed log with:

# clear the log
adb logcat -c
# enable more logging
adb shell setprop debug.mono.log default,assembly,mono_log_level=debug,mono_log_mask=all
# make the app crash
# save the log (share it here)
adb logcat -d > log.txt

Later, when you want to disable the logging, call adb shell setprop debug.mono.log "''" or reboot the device.