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

[tests] enable .NET 7 LLVM tests without Profiled AOT #7030

Closed

Conversation

jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented May 24, 2022

Context: dotnet/runtime#68914

We found that the issue with LLVM only occurs when using Profiled AOT.

This is enabled by default for Release builds in .NET 6+, so let's
try using -p:AndroidEnableProfiledAot=false.

This at least gets some of our LLVM test coverage running again.

When testing this, we started getting a crash:

05-24 15:11:36.809  5024  5024 F DEBUG   : Abort message: 'Internal p/invoke symbol 'java-interop @ java_interop_jvm_list' (hash: 0x58c48fc8b89cb484) not found in compile-time map.'

It appeared that Android.App.Application.cctor was running before
JNIEnv.Initialize() is complete:

05-25 11:12:33.177 10812 10812 D Mono    : AOT: FOUND method Android.Runtime.JNIEnv/<>c:.cctor () [0x78e0d04608 - 0x78e0d04678 0x78e0d6f8a0]
05-25 11:12:33.177 10812 10812 D Mono    : Running class .cctor for Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager from 'Mono.Android.dll'
05-25 11:12:33.177 10812 10812 D Mono    : AOT: FOUND method Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager:.cctor () [0x78e0d31d24 - 0x78e0d31d64 0x78e0d6f8a0]
05-25 11:12:33.177 10812 10812 D Mono    : Running class .cctor for Android.App.Application from 'Mono.Android.dll'

By adding an explicit static constructor to Android.App.Application,
this appears to have workaround this issue.

@jonathanpeppers
Copy link
Member Author

This has a different crash now...

05-24 15:11:36.949  5024  5024 F DEBUG   : backtrace:
05-24 15:11:36.949  5024  5024 F DEBUG   :       #00 pc 00000000000943f8  /apex/com.android.runtime/lib64/bionic/libc.so (syscall+24) (BuildId: a08a19770d6696739c847e29c3f5f650)
05-24 15:11:36.949  5024  5024 F DEBUG   :       #01 pc 0000000000097146  /apex/com.android.runtime/lib64/bionic/libc.so (abort+182) (BuildId: a08a19770d6696739c847e29c3f5f650)
05-24 15:11:36.950  5024  5024 F DEBUG   :       #02 pc 0000000000061eaf  /data/app/Mono.Android.NET_Tests-aVF-bOLHay8eTMCUYgx0mg==/split_config.x86_64.apk!libmono-android.release.so (offset 0x1194000) (xamarin::android::internal::MonodroidRuntime::monodroid_pinvoke_override(char const*, char const*)+3263) (BuildId: 869c82afeb44ac0d778961ebb25a103b6aabfc62)

logcat-ReleaseAotLlvm-Mono.Android.NET_Tests.txt

@jonathanpeppers
Copy link
Member Author

If this one works, this time, I need to squash and completely redo the commit message/title on this one.

@jonathanpeppers
Copy link
Member Author

I think the tests are crashing (something new?):

--------- beginning of crash
05-25 21:08:09.733  5169  5189 F libc    : Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x70c820415ff8 in tid 5189 (Instrumentation), pid 5169 (droid.NET_Tests)
05-25 21:08:09.754  5192  5192 I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
05-25 21:08:09.755  1647  1647 I /system/bin/tombstoned: received crash request for pid 5189
05-25 21:08:09.756  5192  5192 I crash_dump64: performing dump of process 5169 (target tid = 5189)
05-25 21:08:09.759  5192  5192 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-25 21:08:09.759  5192  5192 F DEBUG   : Build fingerprint: 'Android/sdk_phone_x86_64/generic_x86_64:10/QPP6.190730.005.B1/5775370:userdebug/test-keys'
05-25 21:08:09.759  5192  5192 F DEBUG   : Revision: '0'
05-25 21:08:09.759  5192  5192 F DEBUG   : ABI: 'x86_64'
05-25 21:08:09.760  5192  5192 F DEBUG   : Timestamp: 2022-05-25 21:08:09+0000
05-25 21:08:09.760  5192  5192 F DEBUG   : pid: 5169, tid: 5189, name: Instrumentation  >>> Mono.Android.NET_Tests <<<
05-25 21:08:09.760  5192  5192 F DEBUG   : uid: 10108
05-25 21:08:09.760  5192  5192 F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x70c820415ff8
05-25 21:08:09.760  5192  5192 F DEBUG   :     rax 000070c8675d0648  rbx 000070c82283ce08  rcx 0000000000000000  rdx 000070c86f7a7600
05-25 21:08:09.760  5192  5192 F DEBUG   :     r8  000070c820416310  r9  000070c8245f7fa0  r10 000070c8214ad650  r11 000070c82468aa20
05-25 21:08:09.760  5192  5192 F DEBUG   :     r12 0000000000000000  r13 000070c82283ce08  r14 000070c82280e828  r15 000070c86f643010
05-25 21:08:09.760  5192  5192 F DEBUG   :     rdi 000070c8fd060850  rsi 000070c8675d0648
05-25 21:08:09.760  5192  5192 F DEBUG   :     rbp 000070c820416000  rsp 000070c820416000  rip 000070c82467b0e4
05-25 21:08:09.898  5192  5192 F DEBUG   : 
05-25 21:08:09.898  5192  5192 F DEBUG   : backtrace:
05-25 21:08:09.898  5192  5192 F DEBUG   :       #00 pc 000000000023a0e4  /data/app/Mono.Android.NET_Tests-dZ4yY1mgtmqKGM3css6quA==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x66b000) (BuildId: 2404ee10b2f49b595a88cd052dcf25304eb5bcb4)
05-25 21:08:09.898  5192  5192 F DEBUG   :       #01 pc 000000000023a3a4  /data/app/Mono.Android.NET_Tests-dZ4yY1mgtmqKGM3css6quA==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x66b000) (BuildId: 2404ee10b2f49b595a88cd052dcf25304eb5bcb4)
05-25 21:08:09.898  5192  5192 F DEBUG   :       #02 pc 000000000018b9a9  /data/app/Mono.Android.NET_Tests-dZ4yY1mgtmqKGM3css6quA==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x66b000) (BuildId: 2404ee10b2f49b595a88cd052dcf25304eb5bcb4)
05-25 21:08:09.898  5192  5192 F DEBUG   :       #03 pc 000000000018b924  /data/app/Mono.Android.NET_Tests-dZ4yY1mgtmqKGM3css6quA==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x66b000) (BuildId: 2404ee10b2f49b595a88cd052dcf25304eb5bcb4)
05-25 21:08:09.898  5192  5192 F DEBUG   :       #04 pc 00000000001c0548  /data/app/Mono.Android.NET_Tests-dZ4yY1mgtmqKGM3css6quA==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x66b000) (BuildId: 2404ee10b2f49b595a88cd052dcf25304eb5bcb4)
05-25 21:08:09.898  5192  5192 F DEBUG   :       #05 pc 00000000001b6dad  /data/app/Mono.Android.NET_Tests-dZ4yY1mgtmqKGM3css6quA==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x66b000) (BuildId: 2404ee10b2f49b595a88cd052dcf25304eb5bcb4)
05-25 21:08:09.898  5192  5192 F DEBUG   :       #06 pc 00000000001b6cf4  /data/app/Mono.Android.NET_Tests-dZ4yY1mgtmqKGM3css6quA==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x66b000) (mono_assembly_get_object_handle+68) (BuildId: 2404ee10b2f49b595a88cd052dcf25304eb5bcb4)
05-25 21:08:09.898  5192  5192 F DEBUG   :       #07 pc 000000000012dd65  /data/app/Mono.Android.NET_Tests-dZ4yY1mgtmqKGM3css6quA==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x66b000) (BuildId: 2404ee10b2f49b595a88cd052dcf25304eb5bcb4)
05-25 21:08:09.898  5192  5192 F DEBUG   :       #08 pc 00000000001486a0  /data/app/Mono.Android.NET_Tests-dZ4yY1mgtmqKGM3css6quA==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0x66b000) (BuildId: 2404ee10b2f49b595a88cd052dcf25304eb5bcb4)
05-25 21:08:09.898  5192  5192 F DEBUG   :       #09 pc 000000000001f6e5  <anonymous:40cc2000>

I'll try this locally.

Context: dotnet/runtime#68914

We found that the issue with LLVM only occurs when using Profiled AOT.

This is enabled by default for `Release` builds in .NET 6+, so let's
try using `-p:AndroidEnableProfiledAot=false`.

This at least gets some of our LLVM test coverage running again.

When testing this, we started getting a crash:

    05-24 15:11:36.809  5024  5024 F DEBUG   : Abort message: 'Internal p/invoke symbol 'java-interop @ java_interop_jvm_list' (hash: 0x58c48fc8b89cb484) not found in compile-time map.'

It appeared that `Android.App.Application.cctor` was running before
`JNIEnv.Initialize()` is complete:

    05-25 11:12:33.177 10812 10812 D Mono    : AOT: FOUND method Android.Runtime.JNIEnv/<>c:.cctor () [0x78e0d04608 - 0x78e0d04678 0x78e0d6f8a0]
    05-25 11:12:33.177 10812 10812 D Mono    : Running class .cctor for Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager from 'Mono.Android.dll'
    05-25 11:12:33.177 10812 10812 D Mono    : AOT: FOUND method Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager:.cctor () [0x78e0d31d24 - 0x78e0d31d64 0x78e0d6f8a0]
    05-25 11:12:33.177 10812 10812 D Mono    : Running class .cctor for Android.App.Application from 'Mono.Android.dll'

By adding an explicit static constructor to `Android.App.Application`,
this appears to have workaround this issue.
@jonathanpeppers
Copy link
Member Author

Ok, one interesting failure:

/Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.0-ci.pr.gh7030.111/targets/Microsoft.Android.Sdk.Aot.targets(91,5):
error : /Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.android-x64/7.0.0-preview.6.22356.1/Sdk/../tools/opt: obj/Release/net7.0-android/android-x64/aot/x86_64/System.Private.CoreLib/temp.bc: error: Invalid record (Producer: 'LLVM11.1.0' Reader: 'LLVM 11.1.0')
[/Users/runner/work/1/s/xamarin-android/tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj]

@jonathanpeppers
Copy link
Member Author

Closing in favor of: #7188

@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant