Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Crash on startup after enabling LLVM #104163

Open
mfeingol opened this issue Jun 14, 2024 · 18 comments
Open

[Android] Crash on startup after enabling LLVM #104163

mfeingol opened this issue Jun 14, 2024 · 18 comments
Labels
area-VM-meta-mono needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration
Milestone

Comments

@mfeingol
Copy link

Description

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

Might relate to #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 [email protected]::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
Copy link
Contributor

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
Copy link

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
Copy link
Author

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

@ninachen03
Copy link

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
Copy link
Author

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
Copy link
Member

@jonathanpeppers any thoughts?

@jonathanpeppers
Copy link
Member

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.

@jonathanpeppers jonathanpeppers transferred this issue from dotnet/maui Jun 28, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jun 28, 2024
@steveisok
Copy link
Member

@mfeingol can you please provide a repro and logs (if possible) so that we can investigate further?

@steveisok steveisok added needs-author-action An issue or pull request that requires more info or actions from the author. and removed untriaged New issue has not been triaged by the area owner labels Jul 18, 2024
@steveisok steveisok added this to the 10.0.0 milestone Jul 18, 2024
@mfeingol
Copy link
Author

@jonathanpeppers, @steveisok: sorry for the delay. Here's a log of the crash:

log.txt

If you need a repro, I can grant you access to my project.

@dotnet-policy-service dotnet-policy-service bot added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed needs-author-action An issue or pull request that requires more info or actions from the author. labels Jul 18, 2024
@steveisok
Copy link
Member

If you need a repro, I can grant you access to my project.

Yeah, we're going to need one. Really tough to tell why even from the logs you posted.

@mfeingol
Copy link
Author

If you need a repro, I can grant you access to my project.

Yeah, we're going to need one. Really tough to tell why even from the logs you posted.

Okay. Who should I add?

@steveisok
Copy link
Member

Okay. Who should I add?
Myself, @fanyang-mono, and @lambdageek

Doing another pass through the log, I do think you hitting the assertion is significant:

ckroads.Android: * Assertion at /__w/1/s/src/mono/mono/mini/aot-runtime.c:5220, condition plt_entry' not met`

@fanyang-mono
Copy link
Member

This is a duplication of #95406

@mfeingol
Copy link
Author

@fanyang-mono: thanks! So I take it:

  1. No repro is needed from my side?
  2. Someone is working on a fix for this?

@steveisok
Copy link
Member

@fanyang-mono: thanks! So I take it:

  1. No repro is needed from my side?
  2. Someone is working on a fix for this?

There may be multiple opportunities to reproduce. I suspect yours might be the easiest. We'll see what's wrong and try to work a fix.

@mfeingol
Copy link
Author

There may be multiple opportunities to reproduce. I suspect yours might be the easiest. We'll see what's wrong and try to work a fix.

@steveisok: I've invited the three of you to my repo. Pull down https://github.com/mfeingol/sideroads/tree/maui and update the project to build release with LLVM enabled. You should see the crash in an emulator at app startup.

@mfeingol
Copy link
Author

@steveisok: any luck reproducing this? Thanks.

@steveisok
Copy link
Member

@mfeingol yeah! We found that our LLVM had function specialization turned on and that messed with our expected mono EH code range. That problem results in the crash you are seeing.

We have fixes for LLVM 16 (.NET 8) and LLVM 19 (.NET 9). The .NET 8 one needs to be shepherded through to make our servicing release.

Here's the .NET 8 fix: dotnet/llvm-project#599

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-VM-meta-mono needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration
Projects
None yet
Development

No branches or pull requests

7 participants