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

Hybrid AOT doesn't work on arm64 device if built with only armv7 architecture selected #1218

Closed
Belorus opened this issue Jan 22, 2018 · 48 comments
Labels
Area: Mono Runtime Mono-related issues: BCL bugs, AOT issues, etc. need-attention A xamarin-android contributor needs to review

Comments

@Belorus
Copy link

Belorus commented Jan 22, 2018

Steps to Reproduce

  1. Create and Empty application
  2. Add <AndroidAotMode>Hybrid</AndroidAotMode> to .csproj
  3. Add <AotAssemblies>true</AotAssemblies> to .csproj

Repro

Expected Behavior

It works

Actual Behavior

It crashes

Version Information

Microsoft Visual Studio Professional 2017
Version 15.5.2
VisualStudio.15.Release/15.5.2+27130.2010
Microsoft .NET Framework
Version 4.7.02046

Installed Version: Professional

Xamarin 4.8.0.753 (6575bd113)
Xamarin.Android SDK 8.1.0.25 (HEAD/d8c6e504f)

Log File

hybridAOT.log

Other

In logs there are warnings like
W linker : /data/app/App1.App1-1/lib/arm/libaot-mscorlib.dll.so: is missing DT_SONAME will use basename as a replacement: "libaot-mscorlib.dll.so"

F libc : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x25f44a4c in tid 12103 (App1.App1)

01-22 20:27:13.783 12150 12150 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-22 20:27:13.784 12150 12150 F DEBUG   : Build fingerprint: 'samsung/heroltexx/herolte:7.0/NRD90M/G930FXXS1DQLC:user/release-keys'
01-22 20:27:13.784 12150 12150 F DEBUG   : Revision: '8'
01-22 20:27:13.785 12150 12150 F DEBUG   : ABI: 'arm'
01-22 20:27:13.785 12150 12150 F DEBUG   : pid: 12103, tid: 12103, name: App1.App1  >>> App1.App1 <<<
01-22 20:27:13.785 12150 12150 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x25f44a4c
01-22 20:27:13.785 12150 12150 F DEBUG   :     r0 00000000  r1 ffe674f4  r2 25f44a74  r3 d9f225f0
01-22 20:27:13.786 12150 12150 F DEBUG   :     r4 00000000  r5 e43f7f28  r6 ffe67908  r7 ffe674ec
01-22 20:27:13.786 12150 12150 F DEBUG   :     r8 d9f225f0  r9 d5a54690  sl ffe67a10  fp ffe67508
01-22 20:27:13.786 12150 12150 F DEBUG   :     ip ffe67494  sp 25f44a5c  lr d9f229c8  pc c64000c0  cpsr 600e0010
01-22 20:27:13.788 12150 12150 F DEBUG   : 
01-22 20:27:13.788 12150 12150 F DEBUG   : backtrace:
01-22 20:27:13.788 12150 12150 F DEBUG   :     #00 pc 001200c0  /data/app/App1.App1-1/lib/arm/libmonosgen-2.0.so
@Belorus Belorus changed the title Hybrid AOT doesn't work Hybrid AOT doesn't work with armv7 architecture selected Jan 22, 2018
@Belorus Belorus changed the title Hybrid AOT doesn't work with armv7 architecture selected Hybrid AOT doesn't work on arm64 device if built with only armv7 architecture selected Jan 22, 2018
@Belorus
Copy link
Author

Belorus commented Jan 22, 2018

Running on Samsung S7 with ARMv8 Exynos 8890 Octa
My assumption was that ARMv8 devices support ARMv7 code (in a same way as x86_64 does that with x86 instructions).

If i select armv8 or both armv7+armv8- everything works.

@bulente
Copy link

bulente commented Jan 22, 2018

@Belorus how are you building your project with Hybrid Aot? Mine was giving method not found error while stripping system.core.dll. Doesn't your project include system.core.dll?

@Belorus
Copy link
Author

Belorus commented Jan 22, 2018

@bulente Nope. It compiles (use steps from first message), but crashes on start (while loading first library).
If i choose armv8 architecture - it works on armv8 device.

@jonpryor
Copy link
Member

@Belorus: what is "armv8"? arm64-v8a?

What's doubly odd is that it's consistency loading the 32-bit arm images, so it's not like it's a mixed 32-bit/64-bit problem:

70e27000-712a5000 r--p 00000000 fd:00 1249                               /system/framework/arm/boot-core-libart.oat
...
c4cff000-c4ff5000 r-xp 00000000 fd:01 197282                             /data/app/App1.App1-1/lib/arm/libaot-mscorlib.dll.so

@Belorus
Copy link
Author

Belorus commented Jan 22, 2018

@jonpryor Binary compiled against armv7a ABI with AArch32 instructions crashes on device with armv8a CPU that natively supports both AArch64 and AArch32. And when compiled against either just arm64v8a or both armv7a & arm64-v8a it works properly on device with armv8a CPU.

@grendello
Copy link
Contributor

It doesn't help much, alas, but it appears to be a problem with corrupt stack:

01-22 20:27:13.598 12103 12103 F libc : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x25f44a4c in tid 12103 (App1.App1)

note the fault address

01-22 20:27:13.785 12150 12150 F DEBUG   : pid: 12103, tid: 12103, name: App1.App1  >>> App1.App1 <<<
01-22 20:27:13.785 12150 12150 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x25f44a4c
01-22 20:27:13.785 12150 12150 F DEBUG   :     r0 00000000  r1 ffe674f4  r2 25f44a74  r3 d9f225f0
01-22 20:27:13.786 12150 12150 F DEBUG   :     r4 00000000  r5 e43f7f28  r6 ffe67908  r7 ffe674ec
01-22 20:27:13.786 12150 12150 F DEBUG   :     r8 d9f225f0  r9 d5a54690  sl ffe67a10  fp ffe67508
01-22 20:27:13.786 12150 12150 F DEBUG   :     ip ffe67494  sp 25f44a5c  lr d9f229c8  pc c64000c0  cpsr 600e0010

And note the value of the sp register here (stack pointer). The fault location is 16 bytes before the stack top, maybe a corrupt return address from a function?

@pjcollins
Copy link
Member

I'm able to reproduce this using a d15-8 preview build (XA 8.4.0.6). I see a similar crash on both 32bit and 64bit devices if I select armeabi-v7a as my only supported architecture (release mode default).

https://gist.github.com/pjcollins/8a9c63ab2e66e6cd6567fbe234dcebc7

@tobiasschulz
Copy link

Any news?

@ysmoradi
Copy link

ysmoradi commented Feb 24, 2019

I reproduced this with latest version of mono (5.18) and xamarin android 9.1 preview (d16.0)
@bulente I wasn't able to build my project using hybrid aot on Windows, but it gets compiled on mac os. As like as other notes in this issue, it crashes on start up. Normal aot is working fine, with or without llvm, but hybrid aot is the one I'm looking for, please fix it. Thanks )-:

This is what I'm getting:

mono-rt 9d9a5000-9d9a6000 r-xp 00000000 b3:0d 24178 /data/app/com.companyname.XamApp-1/lib/arm/libaot-Xamarin.Forms.Platform.dll.so

libc Fatal signal 11 (SIGSEGV), code 2, fault addr 0xa1758c04 in tid 21186 (panyname.XamApp)

@SprengerS
Copy link

How are the priorities to resolve this problem. we are developing an app for big company and need AOT with IL Strip for source code obfuscation. This bug is still present since 1.5 years.

@cjrvdev
Copy link

cjrvdev commented Nov 21, 2019

Exact same error message brendan mentions in #3367 here. Also using Hybrid mode. Any idea on when is this going to be fixed please?

@taublast
Copy link

As time passes pardon for asking, when this issue would be considered important?

@EDMIStephen
Copy link

I guess the work around is to compile for both armv7a & arm64-v8a. I will test this out and see if it works.

@EDMIStephen
Copy link

@taublast The work around for us is to build for both armv7a & arm64-v8a. The APK is huge but the CIL is stripped.

@nexxuno
Copy link

nexxuno commented Jul 5, 2020

@EDMIStephen the bug is not about building the app but actually running the app.

@EDMIStephen
Copy link

EDMIStephen commented Jul 7, 2020

Runs fine on the 10 or so Android devices we have ranging from an S6 running Android 7 up to Android 10 devices. With Hybrid AOT you need to also change your src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets to have the change from https://github.com/xamarin/xamarin-android/pull/4850/files. Sounds like the fix wont be in Visual Studio for a little while. Having <AndroidSupportedAbis> </AndroidSupportedAbis> seems to default to armv7a & arm64-v8a.

So there are 3 issues. An issue with mono and a CIL stripping issue solved by editing the Xamarin Android targets. and the Supported Abis issue. You need all the fixes for this to work.

<DebugType>none</DebugType> <Optimize>true</Optimize> <AssemblyName>Mobile.Droid</AssemblyName> <OutputPath>bin\Release\</OutputPath> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> <Debugger>Xamarin</Debugger> <RunCodeAnalysis>false</RunCodeAnalysis> <AndroidSupportedAbis> </AndroidSupportedAbis> <AndroidEnableMultiDex>true</AndroidEnableMultiDex> <AotAssemblies>true</AotAssemblies> <EnableLLVM>true</EnableLLVM> <AndroidAotMode>Hybrid</AndroidAotMode> <AndroidEnableProfiledAot>false</AndroidEnableProfiledAot> <AndroidDexTool>d8</AndroidDexTool> <AndroidLinkTool>r8</AndroidLinkTool> <AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent> <DebugSymbols>false</DebugSymbols> <AndroidLinkMode>SdkOnly</AndroidLinkMode>

@ysmoradi
Copy link

ysmoradi commented Jul 8, 2020

@EDMIStephen It seems you're following that PR.
Could you please let us know when that PR gets released in preview version of vs?
I'd like to try your solution in upcoming days too. Hope this helps me.
Thanks

@EDMIStephen
Copy link

@EDMIStephen It seems you're following that PR.
Could you please let us know when that PR gets released in preview version of vs?
I'd like to try your solution in upcoming days too. Hope this helps me.
Thanks

#4818 (comment)

@brendanzagaeski
Copy link
Contributor

One other hint to help with getting notifications about availability of the fix for #4818 is if you click the Subscribe button in the right column of the page for #4818, you will get a notification for the comment that will be added to that item when the Preview version that includes the fix is published.

Here's an example of how the comment will look: #4409 (comment).

@EDMIStephen
Copy link

@brendanzagaeski Would it be possible in the interim to report a warning if hybrid AOT is enabled and only one of armv7a & arm64-v8a are chosen in AndroidSupportedAbis. That way even though this issue is not fixed people wont spend time trying to find out why. I know I spent a lot of time before I came across this bug from over 2 years ago.

brendanzagaeski added a commit to brendanzagaeski/xamarin-android that referenced this issue Jul 28, 2020
…abi-v7a

Context: dotnet#1218 (comment)

The undocumented, experimental `Hybrid` value for the
`$(AndroidAotMode)` MSBuild property is not currently compatible with
the armeabi-v7a target ABI.  Attempting to run an app built with
`$(AndroidAotMode)`=`Hybrid` in an armeabi-v7a environment results in a
crash.

Since it is known that this configuration currently produces a crash,
emit a build error for it to improve the visibility of the known issue
and reduce the time users might spend searching for the cause of the
crash.

Example of the current crash:

	F libc    : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x913a50c8 in tid 31140 (ppxamarinforms1)
	W         : debuggerd: handling request: pid=31140 uid=10146 gid=10146 tid=31140
	F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	F DEBUG   : Build fingerprint: 'motorola/perry_metropcs_c/perry:7.1.1/NCQS26.69-64-21/33:user/release-keys'
	F DEBUG   : Revision: 'p3b0'
	F DEBUG   : ABI: 'arm'
	F DEBUG   : pid: 31140, tid: 31140, name: ppxamarinforms1  >>> com.companyname.mobileappxamarinforms1 <<<
	F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x913a50c8
	F DEBUG   :     r0 be9384d4  r1 00000000  r2 be9385a0  r3 9320b1c0
	F DEBUG   :     r4 00000000  r5 94167208  r6 00000000  r7 be938584
	F DEBUG   :     r8 be938838  r9 ae040008  sl 00000000  fp be9385a0
	F DEBUG   :     ip 913a50c8  sp be9384e4  lr 942a8420  pc 913a50c8  cpsr 000f0010
	F DEBUG   :
	F DEBUG   : backtrace:
	F DEBUG   :     #00 pc 000250c8  [anon:libc_malloc:91380000]
	F DEBUG   :     #1 pc 0000141c  <anonymous:942a7000>
	W ActivityManager: Activity pause timeout for ActivityRecord{7ded4d1 u0 com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity t5740}
	I ActivityManager: Killing 30471:com.google.android.apps.fireball/u0a145 (adj 906): empty dotnet#13
	D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ], android.os.BinderProxy@f4c4e10)
	D ActivityManager: cleanUpApplicationRecord -- 30471
	E ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ]
	W         : debuggerd: resuming target 31140
	I BootReceiver: Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
	W ActivityManager:   Force finishing activity com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity
	I Zygote  : Process 31140 exited due to signal (11)
@EDMIStephen
Copy link

sed by Micro

I'm not sure Hybrid AOT should be considered non essential. It seems like the only solution for CIL stripping on Android.

Obscurity is not a legitimate way to protect your source code. Decompiling obfuscated IL back to C# is trivial. Dotfuscator, .NET Reactor, or Babelfor.NET are not replacements for CIL stripping. CIL stripping reduces the IL in your APK from your full source to the C# equivalent of a C++ header file, ex. method prototypes, non-local variable names, etc. Method bodies are completely stripped. As I understand it, it basically just leaves enough IL to support the relevant System.Reflection namespaces.

To put a finer point on it, I think that the crux of the issue is that CIL stripping needs to be fully supported for both armeabi-v7a and arm64-v8a by some approach to AOT. I wouldn't care if it comes by way of fully supporting hybrid AOT, profiled AOT, or some other AOT approach, as long as any one of them is fully supported. Without CIL stripping, we either have to be incredibly risk tolerant or just ignorant to publish apps to Google Play. Even private distribution is sketchier. It's really hard to justify the major effort it takes to build an app when someone can have a copy of all your hard work with minimal effort.

I've seen tons of posts on SO, Reddit, Xamarin Community Forums, etc. asking about why we don't see more Xamarin apps on the app stores, I'd say this has plenty to do with it.

I'm very grateful for Xamarin, and for the experimental hybrid AOT compilation that lets us strip IL from arm64-v8a APKs. Thanks to everyone that's made that possible. I just wanted to share my experience as a developer, specifically that it's painful to have to choose between the armeabi-v7a user base and securing my source code, as I believe there are many others that feel similarly. Maybe the best way to bring attention to the specific issue, that is, fully supported CIL stripping for both armeabi-v7a and arm64-v8a devices, is to open a new feature request? Or does someone already know of a such a request?

I completely agree. The amount of time I have spend tracking through the Xamarin Android code to try find work arounds is insane. Managing to get CIL stripping working on arm64-v8a is a life saver. We could not release without it. Our customer base is limited by us not being able to support armeabi-v7a. Hybrid AOT really needs to come out of experimental and become a first class citizen with support for armeabi-v7a in the roadmap.

@EDMIStephen
Copy link

be nice. The above solution is just a workaround for local builds if I understand correctly

It will work in all builds where you can edit src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets. Once this PR makes it all the way through then hybrid aot should start building everywhere to run on arm64-v8a without manually editing that file.

@nexxuno
Copy link

nexxuno commented Sep 9, 2020

sed by Micro

I'm not sure Hybrid AOT should be considered non essential. It seems like the only solution for CIL stripping on Android.

Obscurity is not a legitimate way to protect your source code. Decompiling obfuscated IL back to C# is trivial. Dotfuscator, .NET Reactor, or Babelfor.NET are not replacements for CIL stripping. CIL stripping reduces the IL in your APK from your full source to the C# equivalent of a C++ header file, ex. method prototypes, non-local variable names, etc. Method bodies are completely stripped. As I understand it, it basically just leaves enough IL to support the relevant System.Reflection namespaces.

To put a finer point on it, I think that the crux of the issue is that CIL stripping needs to be fully supported for both armeabi-v7a and arm64-v8a by some approach to AOT. I wouldn't care if it comes by way of fully supporting hybrid AOT, profiled AOT, or some other AOT approach, as long as any one of them is fully supported. Without CIL stripping, we either have to be incredibly risk tolerant or just ignorant to publish apps to Google Play. Even private distribution is sketchier. It's really hard to justify the major effort it takes to build an app when someone can have a copy of all your hard work with minimal effort.

I've seen tons of posts on SO, Reddit, Xamarin Community Forums, etc. asking about why we don't see more Xamarin apps on the app stores, I'd say this has plenty to do with it.

I'm very grateful for Xamarin, and for the experimental hybrid AOT compilation that lets us strip IL from arm64-v8a APKs. Thanks to everyone that's made that possible. I just wanted to share my experience as a developer, specifically that it's painful to have to choose between the armeabi-v7a user base and securing my source code, as I believe there are many others that feel similarly. Maybe the best way to bring attention to the specific issue, that is, fully supported CIL stripping for both armeabi-v7a and arm64-v8a devices, is to open a new feature request? Or does someone already know of a such a request?

We all know what AOT does and that cil stripping would be better. But at the moment obfuscation is the only solution. This is not a feature request, they had the feature we need but it was bugged and at MS they decided it's not a priority to keep it working.

@hyo1411
Copy link

hyo1411 commented Sep 14, 2020

how complicated of fixing this bug? maybe someone looking rather than waiting for Microsoft

@nexxuno
Copy link

nexxuno commented Sep 14, 2020

how complicated of fixing this bug? maybe someone looking rather than waiting for Microsoft

Please submit your PR when you've managed to fix it.

brendanzagaeski added a commit to brendanzagaeski/xamarin-android that referenced this issue Nov 8, 2020
…abi-v7a

Context: dotnet#1218 (comment)

The undocumented, experimental `Hybrid` value for the
`$(AndroidAotMode)` MSBuild property is not currently compatible with
the armeabi-v7a target ABI.  Attempting to run an app built with
`$(AndroidAotMode)`=`Hybrid` in an armeabi-v7a environment results in a
crash.

Since it is known that this configuration currently produces a crash,
emit a build error for it to improve the visibility of the known issue
and reduce the time users might spend searching for the cause of the
crash.

Example of the current crash:

	F libc    : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x913a50c8 in tid 31140 (ppxamarinforms1)
	W         : debuggerd: handling request: pid=31140 uid=10146 gid=10146 tid=31140
	F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	F DEBUG   : Build fingerprint: 'motorola/perry_metropcs_c/perry:7.1.1/NCQS26.69-64-21/33:user/release-keys'
	F DEBUG   : Revision: 'p3b0'
	F DEBUG   : ABI: 'arm'
	F DEBUG   : pid: 31140, tid: 31140, name: ppxamarinforms1  >>> com.companyname.mobileappxamarinforms1 <<<
	F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x913a50c8
	F DEBUG   :     r0 be9384d4  r1 00000000  r2 be9385a0  r3 9320b1c0
	F DEBUG   :     r4 00000000  r5 94167208  r6 00000000  r7 be938584
	F DEBUG   :     r8 be938838  r9 ae040008  sl 00000000  fp be9385a0
	F DEBUG   :     ip 913a50c8  sp be9384e4  lr 942a8420  pc 913a50c8  cpsr 000f0010
	F DEBUG   :
	F DEBUG   : backtrace:
	F DEBUG   :     #00 pc 000250c8  [anon:libc_malloc:91380000]
	F DEBUG   :     #1 pc 0000141c  <anonymous:942a7000>
	W ActivityManager: Activity pause timeout for ActivityRecord{7ded4d1 u0 com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity t5740}
	I ActivityManager: Killing 30471:com.google.android.apps.fireball/u0a145 (adj 906): empty dotnet#13
	D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ], android.os.BinderProxy@f4c4e10)
	D ActivityManager: cleanUpApplicationRecord -- 30471
	E ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ]
	W         : debuggerd: resuming target 31140
	I BootReceiver: Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
	W ActivityManager:   Force finishing activity com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity
	I Zygote  : Process 31140 exited due to signal (11)

Other changes:

Update the `HybridAOT` test to cover the new error.

Correct the `BuildIncrementalAot` test so that it sets
`$(AndroidSupportedAbis)`.  A side effect is that the test cases that
use `$(AndroidAotMode)`=`Full` now build successfully.  Note that
although those test cases now build successfully, the resulting app
packages abort when run on device because Xamarin.Android requires JIT
compilation:

	Unhandled Exception:
	System.ExecutionEngineException: Attempting to JIT compile method '(wrapper other) void Java.Interop.JavaVMInterface:PtrToStructure (intptr,object)' while running in aot-only mode.

TODO: Add a build error for `$(AndroidAotMode)`=`Full`, likely by
updating error XA3002.
brendanzagaeski added a commit to brendanzagaeski/xamarin-android that referenced this issue Nov 8, 2020
…abi-v7a

Context: dotnet#1218 (comment)

The undocumented, experimental `Hybrid` value for the
`$(AndroidAotMode)` MSBuild property is not currently compatible with
the armeabi-v7a target ABI.  Attempting to run an app built with
`$(AndroidAotMode)`=`Hybrid` in an armeabi-v7a environment results in a
crash.

Since it is known that this configuration currently produces a crash,
emit a build error for it to improve the visibility of the known issue
and reduce the time users might spend searching for the cause of the
crash.

Example of the current crash:

	F libc    : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x913a50c8 in tid 31140 (ppxamarinforms1)
	W         : debuggerd: handling request: pid=31140 uid=10146 gid=10146 tid=31140
	F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	F DEBUG   : Build fingerprint: 'motorola/perry_metropcs_c/perry:7.1.1/NCQS26.69-64-21/33:user/release-keys'
	F DEBUG   : Revision: 'p3b0'
	F DEBUG   : ABI: 'arm'
	F DEBUG   : pid: 31140, tid: 31140, name: ppxamarinforms1  >>> com.companyname.mobileappxamarinforms1 <<<
	F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x913a50c8
	F DEBUG   :     r0 be9384d4  r1 00000000  r2 be9385a0  r3 9320b1c0
	F DEBUG   :     r4 00000000  r5 94167208  r6 00000000  r7 be938584
	F DEBUG   :     r8 be938838  r9 ae040008  sl 00000000  fp be9385a0
	F DEBUG   :     ip 913a50c8  sp be9384e4  lr 942a8420  pc 913a50c8  cpsr 000f0010
	F DEBUG   :
	F DEBUG   : backtrace:
	F DEBUG   :     #00 pc 000250c8  [anon:libc_malloc:91380000]
	F DEBUG   :     #1 pc 0000141c  <anonymous:942a7000>
	W ActivityManager: Activity pause timeout for ActivityRecord{7ded4d1 u0 com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity t5740}
	I ActivityManager: Killing 30471:com.google.android.apps.fireball/u0a145 (adj 906): empty dotnet#13
	D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ], android.os.BinderProxy@f4c4e10)
	D ActivityManager: cleanUpApplicationRecord -- 30471
	E ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ]
	W         : debuggerd: resuming target 31140
	I BootReceiver: Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
	W ActivityManager:   Force finishing activity com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity
	I Zygote  : Process 31140 exited due to signal (11)

Other changes:

Update the `HybridAOT` test to cover the new error.

Correct the `BuildIncrementalAot` test so that it sets
`$(AndroidSupportedAbis)`.  A side effect is that the test cases that
use `$(AndroidAotMode)`=`Full` now build successfully.  Note that
although those test cases now build successfully, the resulting app
packages abort when run on device because Xamarin.Android requires JIT
compilation:

	Unhandled Exception:
	System.ExecutionEngineException: Attempting to JIT compile method '(wrapper other) void Java.Interop.JavaVMInterface:PtrToStructure (intptr,object)' while running in aot-only mode.

TODO: Add a build error for `$(AndroidAotMode)`=`Full`, likely by
updating error XA3002.
brendanzagaeski added a commit to brendanzagaeski/xamarin-android that referenced this issue Nov 12, 2020
…abi-v7a

Context: dotnet#1218 (comment)

The undocumented, experimental `Hybrid` value for the
`$(AndroidAotMode)` MSBuild property is not currently compatible with
the armeabi-v7a target ABI.  Attempting to run an app built with
`$(AndroidAotMode)`=`Hybrid` in an armeabi-v7a environment results in a
crash.

Since it is known that this configuration currently produces a crash,
emit a build error for it to improve the visibility of the known issue
and reduce the time users might spend searching for the cause of the
crash.

Example of the current crash:

	F libc    : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x913a50c8 in tid 31140 (ppxamarinforms1)
	W         : debuggerd: handling request: pid=31140 uid=10146 gid=10146 tid=31140
	F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	F DEBUG   : Build fingerprint: 'motorola/perry_metropcs_c/perry:7.1.1/NCQS26.69-64-21/33:user/release-keys'
	F DEBUG   : Revision: 'p3b0'
	F DEBUG   : ABI: 'arm'
	F DEBUG   : pid: 31140, tid: 31140, name: ppxamarinforms1  >>> com.companyname.mobileappxamarinforms1 <<<
	F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x913a50c8
	F DEBUG   :     r0 be9384d4  r1 00000000  r2 be9385a0  r3 9320b1c0
	F DEBUG   :     r4 00000000  r5 94167208  r6 00000000  r7 be938584
	F DEBUG   :     r8 be938838  r9 ae040008  sl 00000000  fp be9385a0
	F DEBUG   :     ip 913a50c8  sp be9384e4  lr 942a8420  pc 913a50c8  cpsr 000f0010
	F DEBUG   :
	F DEBUG   : backtrace:
	F DEBUG   :     #00 pc 000250c8  [anon:libc_malloc:91380000]
	F DEBUG   :     #1 pc 0000141c  <anonymous:942a7000>
	W ActivityManager: Activity pause timeout for ActivityRecord{7ded4d1 u0 com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity t5740}
	I ActivityManager: Killing 30471:com.google.android.apps.fireball/u0a145 (adj 906): empty dotnet#13
	D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ], android.os.BinderProxy@f4c4e10)
	D ActivityManager: cleanUpApplicationRecord -- 30471
	E ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ]
	W         : debuggerd: resuming target 31140
	I BootReceiver: Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
	W ActivityManager:   Force finishing activity com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity
	I Zygote  : Process 31140 exited due to signal (11)

Other changes:

Update the `HybridAOT` test to cover the new error.

Add a new `AndroidAotModeHybridAbortsOnArmeabiV7a` on-device test to
remind the team to remove the error if hybrid AOT becomes compatible
with armeabi-v7a in the future.

Correct the `BuildIncrementalAot` test so that it sets
`$(AndroidSupportedAbis)`.  A side effect is that the test cases that
use `$(AndroidAotMode)`=`Full` now build successfully.  Note that
although those test cases now build successfully, the resulting app
packages abort when run on device because Xamarin.Android requires JIT
compilation:

	Unhandled Exception:
	System.ExecutionEngineException: Attempting to JIT compile method '(wrapper other) void Java.Interop.JavaVMInterface:PtrToStructure (intptr,object)' while running in aot-only mode.

TODO: Add a build error for `$(AndroidAotMode)`=`Full`, likely by
updating error XA3002.
brendanzagaeski added a commit to brendanzagaeski/xamarin-android that referenced this issue Nov 12, 2020
…abi-v7a

Context: dotnet#1218 (comment)

The undocumented, experimental `Hybrid` value for the
`$(AndroidAotMode)` MSBuild property is not currently compatible with
the armeabi-v7a target ABI.  Attempting to run an app built with
`$(AndroidAotMode)`=`Hybrid` in an armeabi-v7a environment results in a
crash.

Since it is known that this configuration currently produces a crash,
emit a build error for it to improve the visibility of the known issue
and reduce the time users might spend searching for the cause of the
crash.

Example of the current crash:

	F libc    : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x913a50c8 in tid 31140 (ppxamarinforms1)
	W         : debuggerd: handling request: pid=31140 uid=10146 gid=10146 tid=31140
	F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	F DEBUG   : Build fingerprint: 'motorola/perry_metropcs_c/perry:7.1.1/NCQS26.69-64-21/33:user/release-keys'
	F DEBUG   : Revision: 'p3b0'
	F DEBUG   : ABI: 'arm'
	F DEBUG   : pid: 31140, tid: 31140, name: ppxamarinforms1  >>> com.companyname.mobileappxamarinforms1 <<<
	F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x913a50c8
	F DEBUG   :     r0 be9384d4  r1 00000000  r2 be9385a0  r3 9320b1c0
	F DEBUG   :     r4 00000000  r5 94167208  r6 00000000  r7 be938584
	F DEBUG   :     r8 be938838  r9 ae040008  sl 00000000  fp be9385a0
	F DEBUG   :     ip 913a50c8  sp be9384e4  lr 942a8420  pc 913a50c8  cpsr 000f0010
	F DEBUG   :
	F DEBUG   : backtrace:
	F DEBUG   :     #00 pc 000250c8  [anon:libc_malloc:91380000]
	F DEBUG   :     #1 pc 0000141c  <anonymous:942a7000>
	W ActivityManager: Activity pause timeout for ActivityRecord{7ded4d1 u0 com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity t5740}
	I ActivityManager: Killing 30471:com.google.android.apps.fireball/u0a145 (adj 906): empty dotnet#13
	D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ], android.os.BinderProxy@f4c4e10)
	D ActivityManager: cleanUpApplicationRecord -- 30471
	E ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ]
	W         : debuggerd: resuming target 31140
	I BootReceiver: Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
	W ActivityManager:   Force finishing activity com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity
	I Zygote  : Process 31140 exited due to signal (11)

Other changes:

Update the `HybridAOT` test to cover the new error.

Correct the `BuildIncrementalAot` test so that it sets
`$(AndroidSupportedAbis)`.  A side effect is that the test cases that
use `$(AndroidAotMode)`=`Full` now build successfully.  Note that
although those test cases now build successfully, the resulting app
packages abort when run on device because Xamarin.Android requires JIT
compilation:

	Unhandled Exception:
	System.ExecutionEngineException: Attempting to JIT compile method '(wrapper other) void Java.Interop.JavaVMInterface:PtrToStructure (intptr,object)' while running in aot-only mode.

TODO: Add a build error for `$(AndroidAotMode)`=`Full`, likely by
updating error XA3002.
@simon10says
Copy link

@brendanzagaeski , based on your above commits, am I right to say that Microsoft decided not to support/fix hybrid AOT for armebi-v7a?

@brendanzagaeski
Copy link
Contributor

@simon10says, as far as I know, there hasn't been a decision against solving the hybrid AOT compatibility issue on armeabi-v7a. That said, I think it's unlikely hybrid AOT will become compatible with armeabi-v7a before .NET 6. Most of the new work on the Mono runtime is now in the combined dotnet/runtime codebase that will be used to run Android applications in .NET 6. (For a little background info about Xamarin.Android in .NET 6, see the blog post from May about "What’s Next for Xamarin")

One next question would then be how AOT will work for Android apps with the Mono runtime in .NET 6. Unfortunately, I'm not familiar with the details of the AOT story for Android apps in .NET 6 or how the plan for it is evolving.

@jxbrenner
Copy link

jxbrenner commented Nov 21, 2020

@simon10says, as far as I know, there hasn't been a decision against solving the hybrid AOT compatibility issue on armeabi-v7a. That said, I think it's unlikely hybrid AOT will become compatible with armeabi-v7a before .NET 6. Most of the new work on the Mono runtime is now in the combined dotnet/runtime codebase that will be used to run Android applications in .NET 6. (For a little background info about Xamarin.Android in .NET 6, see the blog post from May about "What’s Next for Xamarin")

One next question would then be how AOT will work for Android apps with the Mono runtime in .NET 6. Unfortunately, I'm not familiar with the details of the AOT story for Android apps in .NET 6 or how the plan for it is evolving.

Based on this response I've created a feature request for AoT compilation and CIL stripping in the .NET runtime repo: dotnet/runtime#44855. If the feature is important to you, please upvote or comment to illustrate that to the development team. Please take the time share your thoughts and experience in the issue. As far as I can tell, it's our best shot at ensuring IL stripping is fully supported for Android in .NET 6.

jonpryor pushed a commit that referenced this issue Dec 9, 2020
…4966)

Context: #1218 (comment)

The undocumented, experimental, `Hybrid` value for the
`$(AndroidAotMode)` MSBuild property is not currently compatible with
the armeabi-v7a target ABI.  Attempting to run an app built with
`$(AndroidAotMode)`=`Hybrid` in an armeabi-v7a environment results in
a crash:

	F libc    : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x913a50c8 in tid 31140 (ppxamarinforms1)
	W         : debuggerd: handling request: pid=31140 uid=10146 gid=10146 tid=31140
	F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	F DEBUG   : Build fingerprint: 'motorola/perry_metropcs_c/perry:7.1.1/NCQS26.69-64-21/33:user/release-keys'
	F DEBUG   : Revision: 'p3b0'
	F DEBUG   : ABI: 'arm'
	F DEBUG   : pid: 31140, tid: 31140, name: ppxamarinforms1  >>> com.companyname.mobileappxamarinforms1 <<<
	F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x913a50c8
	F DEBUG   :     r0 be9384d4  r1 00000000  r2 be9385a0  r3 9320b1c0
	F DEBUG   :     r4 00000000  r5 94167208  r6 00000000  r7 be938584
	F DEBUG   :     r8 be938838  r9 ae040008  sl 00000000  fp be9385a0
	F DEBUG   :     ip 913a50c8  sp be9384e4  lr 942a8420  pc 913a50c8  cpsr 000f0010
	F DEBUG   :
	F DEBUG   : backtrace:
	F DEBUG   :     #00 pc 000250c8  [anon:libc_malloc:91380000]
	F DEBUG   :     #1 pc 0000141c  <anonymous:942a7000>
	W ActivityManager: Activity pause timeout for ActivityRecord{7ded4d1 u0 com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity t5740}
	I ActivityManager: Killing 30471:com.google.android.apps.fireball/u0a145 (adj 906): empty #13
	D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ], android.os.BinderProxy@f4c4e10)
	D ActivityManager: cleanUpApplicationRecord -- 30471
	E ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ]
	W         : debuggerd: resuming target 31140
	I BootReceiver: Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
	W ActivityManager:   Force finishing activity com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity
	I Zygote  : Process 31140 exited due to signal (11)

Since it is known that this configuration currently produces a crash,
emit a build error for it to improve the visibility of the known
issue and reduce the time users might spend searching for the cause
of the crash.

Other changes:

Update the `HybridAOT` test to cover the new error.

Correct the `IncrementalBuildTest.BuildIncrementalAot()` test so that
it sets `$(AndroidSupportedAbis)`.  A side effect is that the test
cases that use `$(AndroidAotMode)`=`Full` now build successfully.
Note that although those test cases now build successfully, the
resulting app packages abort when run on device because Xamarin.Android
requires JIT compilation:

	Unhandled Exception:
	System.ExecutionEngineException: Attempting to JIT compile method '(wrapper other) void Java.Interop.JavaVMInterface:PtrToStructure (intptr,object)' while running in aot-only mode.

TODO: Add a build error for `$(AndroidAotMode)`=`Full`, likely by
updating error XA3002.
@ghost
Copy link

ghost commented Mar 22, 2021

Hello! Is there anything new on the topic? Any workaround for Hybrid AOT on armeabi-v7a?

@ghost
Copy link

ghost commented Mar 22, 2021

I like how fast my app performs with Hybrid AOT. Also, not f....ing with Dotfuscator is even better, than performance improvements. This feature must be supported by Microsoft.

jonpryor added a commit to jonpryor/xamarin-android that referenced this issue Aug 26, 2021
Changes: xamarin/monodroid@fb0d502...5676b84

  * xamarin/monodroid@5676b84b4: Bump to xamarin/androidtools@0abc0d7c (dotnet#1223)
  * xamarin/monodroid@daf1aa909: [optimization] Replace 'new T[0]' with 'Array.Empty<T> ()' to reduce allocations. (dotnet#1221)
  * xamarin/monodroid@fb848118b: [tools/msbuild] Check `device.Properties.BuildVersionSdk` for `-1` (dotnet#1222)
  * xamarin/monodroid@489a389d1: [tools/msbuild] Check device additional output to see if its the same device. (dotnet#1218)
  * xamarin/monodroid@209a7c352: [tests/AndroidMSBuildTests] Remove Unused Unit Tests (dotnet#1215)
jonpryor added a commit that referenced this issue Aug 27, 2021
Changes: xamarin/monodroid@fb0d502...5676b84

  * xamarin/monodroid@5676b84b4: Bump to xamarin/androidtools@0abc0d7c (#1223)
  * xamarin/monodroid@daf1aa909: [optimization] Replace 'new T[0]' with 'Array.Empty<T> ()' to reduce allocations. (#1221)
  * xamarin/monodroid@fb848118b: [tools/msbuild] Check `device.Properties.BuildVersionSdk` for `-1` (#1222)
  * xamarin/monodroid@489a389d1: [tools/msbuild] Check device additional output to see if its the same device. (#1218)
  * xamarin/monodroid@209a7c352: [tests/AndroidMSBuildTests] Remove Unused Unit Tests (#1215)
@jpobst jpobst added the Area: Mono Runtime Mono-related issues: BCL bugs, AOT issues, etc. label Oct 18, 2022
@jonathanpeppers jonathanpeppers added the possibly-stale Issues that are potentially no longer relevant. label Dec 13, 2022
@ghost
Copy link

ghost commented Dec 13, 2022

We suspect this issue is stale and no longer relevant. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.

@MaximMikhisor
Copy link

Are you going do not support Hybrid AOT on armeabi-v7a?

@ghost ghost added need-attention A xamarin-android contributor needs to review and removed possibly-stale Issues that are potentially no longer relevant. labels Dec 13, 2022
@jpobst
Copy link
Contributor

jpobst commented May 2, 2024

With support for Classic Xamarin.Android ended May 1st, 2024, this issue is likely no longer relevant.

If this still persists in .NET 8+, please open a new issue with updated information based on net8.0-android or greater. Please include a link to this issue for context.

@jpobst jpobst closed this as completed May 2, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: Mono Runtime Mono-related issues: BCL bugs, AOT issues, etc. need-attention A xamarin-android contributor needs to review
Projects
None yet
Development

No branches or pull requests