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

[Xamarin.Android] Assertion tramp-arm64.c:52, condition '((ins >> 24) & 0x1f) == 0x10' not met #7352

Closed
jeromelaban opened this issue Sep 7, 2022 · 33 comments
Assignees
Labels
Area: Mono Runtime Mono-related issues: BCL bugs, AOT issues, etc.

Comments

@jeromelaban
Copy link

jeromelaban commented Sep 7, 2022

Android application type

Classic Xamarin.Android (MonoAndroid12.0, etc.)

Affected platform version

VS 2022 of Azure Devops agents 20220828.1

Description

Using Profiled AOT, the following crash happens when running on device (A surface Duo 2 here). Note that the issue does not happen when using "normal" AOT without a profile. I'm not able to reproduce on net6.0 because there are no easy steps to create a profile.

09-06 22:33:33.042  8303  8303 I crash_dump64: performing dump of process 8271 (target tid = 8271)
09-06 22:33:33.045  8303  8303 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
09-06 22:33:33.045  8303  8303 F DEBUG   : Build fingerprint: 'surface/duo2/duo2:11/2022.519.47/202205190047:user/release-keys'
09-06 22:33:33.045  8303  8303 F DEBUG   : Revision: '0'
09-06 22:33:33.045  8303  8303 F DEBUG   : ABI: 'arm64'
09-06 22:33:33.045  8303  8303 F DEBUG   : Timestamp: 2022-09-06 22:33:33-0400
09-06 22:33:33.045  8303  8303 F DEBUG   : pid: 8271, tid: 8271, name: ive.uno.ui.demo  >>> com.nventive.uno.ui.demo <<<
09-06 22:33:33.045  8303  8303 F DEBUG   : uid: 10308
09-06 22:33:33.045  8303  8303 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
09-06 22:33:33.046  8303  8303 F DEBUG   : Abort message: '* Assertion at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mono/mini/tramp-arm64.c:52, condition `((ins >> 24) & 0x1f) == 0x10' not met
09-06 22:33:33.046  8303  8303 F DEBUG   : '
09-06 22:33:33.046  8303  8303 F DEBUG   :     x0  0000000000000000  x1  000000000000204f  x2  0000000000000006  x3  0000007fccd03f00
09-06 22:33:33.046  8303  8303 F DEBUG   :     x4  fefefefefefefeff  x5  fefefefefefefeff  x6  fefefefefefefeff  x7  7f7f7f7f7f7f7f7f
09-06 22:33:33.046  8303  8303 F DEBUG   :     x8  00000000000000f0  x9  2e64e12967d126ae  x10 0000000000000000  x11 ffffffc0fffffbdf
09-06 22:33:33.046  8303  8303 F DEBUG   :     x12 0000000000000001  x13 00000000000000a3  x14 0000c8057b4e42db  x15 0000000034155555
09-06 22:33:33.046  8303  8303 F DEBUG   :     x16 0000007c8968dc80  x17 0000007c8966f870  x18 0000000000000008  x19 000000000000204f
09-06 22:33:33.046  8303  8303 F DEBUG   :     x20 000000000000204f  x21 00000000ffffffff  x22 000000798a6a0320  x23 000000798a7de480
09-06 22:33:33.046  8303  8303 F DEBUG   :     x24 b400007ae68b9bd0  x25 0000007990511000  x26 000000798a6a02e8  x27 0000000000000000
09-06 22:33:33.046  8303  8303 F DEBUG   :     x28 0000007c8be69000  x29 0000007fccd03f80
09-06 22:33:33.046  8303  8303 F DEBUG   :     lr  0000007c896232a0  sp  0000007fccd03ee0  pc  0000007c896232cc  pst 0000000000001000
09-06 22:33:33.046  8303  8303 F DEBUG   : backtrace:
09-06 22:33:33.046  8303  8303 F DEBUG   :       #00 pc 000000000004e2cc  /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) (BuildId: 49090ae59e6ae37f8beae53c551820ad)
09-06 22:33:33.046  8303  8303 F DEBUG   :       #01 pc 000000000028e850  /data/app/~~6hfhmZOL2T6K4N24pAS5VQ==/com.nventive.uno.ui.demo-ErE4OrB5kZmmdiQVwrImHw==/lib/arm64/libmonosgen-2.0.so (monoeg_assert_abort+24)
09-06 22:33:33.126   854   854 E tombstoned: Tombstone written to: /data/tombstones/tombstone_28

Steps to Reproduce

  1. checkout unoplatform/Uno.Gallery@bca93dd
  2. Build Uno.Gallery/Uno.Gallery.Droid/Uno.Gallery.Droid.csproj in Release
  3. Run on device.

Did you find any workaround?

Relevant log output

No response

@jeromelaban jeromelaban added Area: App+Library Build Issues when building Library projects or Application projects. needs-triage Issues that need to be assigned. labels Sep 7, 2022
@dellis1972 dellis1972 removed the needs-triage Issues that need to be assigned. label Sep 7, 2022
@dellis1972
Copy link
Contributor

@grendello do we need any additional info to investigate this?

@grendello
Copy link
Contributor

@dellis1972 someone from the Runtime team needs to look at it, however a full log would be a good thing to have.

@jeromelaban would you mind recording and attaching the crash log using instructions below?

$ adb shell setprop debug.mono.log default,assembly,mono_log_mask=all,mono_log_level=debug
$ adb logcat -G 16M
$ adb logcat -c
# Run the app here and after it crashes, do
$ adb logcat -d > log.txt

@grendello grendello added need-info Issues that need more information from the author. Area: Mono Runtime Mono-related issues: BCL bugs, AOT issues, etc. and removed Area: App+Library Build Issues when building Library projects or Application projects. labels Sep 7, 2022
@ghost
Copy link

ghost commented Sep 7, 2022

Hi @jeromelaban. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@jeromelaban
Copy link
Author

Here's the log:
log.txt

@ghost ghost added need-attention A xamarin-android contributor needs to review and removed need-info Issues that need more information from the author. labels Sep 7, 2022
@grendello
Copy link
Contributor

grendello commented Sep 7, 2022

@jeromelaban hm, I spotted something interesting in your log above:

09-07 10:03:33.957  2929  2929 V Mono    : AOT: FOUND method System.OutOfMemoryException:.ctor (string) [0x79886bd360 - 0x79886bd3c4 0x798864fa07]
09-07 10:03:33.957  2929  2929 V Mono    : AOT NOT FOUND: (wrapper runtime-invoke) <Module>:runtime_invoke_void__this___object (object,intptr,intptr,intptr).
09-07 10:03:33.957  2929  2929 V Mono    : AOT: FOUND method System.Exception:.cctor () [0x79886c4b60 - 0x79886c4bc4 0x798864fbef]
09-07 10:03:33.957  2929  2929 V Mono    : AOT NOT FOUND: (wrapper runtime-invoke) object:runtime_invoke_void (object,intptr,intptr,intptr).
09-07 10:03:33.957  2929  2929 F .ui.demo.canar: * Assertion at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mono/mini/tramp-arm64.c:52, condition `((ins >> 24) & 0x1f) == 0x10' not met
--------- beginning of crash
09-07 10:03:33.957  2929  2929 F libc    : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 2929 (.ui.demo.canary), pid 2929 (.ui.demo.canary)

It looks like the runtime asserts when OutOfMemoryException is being constructed?

@jeromelaban
Copy link
Author

Definitely looks that way, though I don't believe we're doing anything with OutOfMemoryException.

@grendello
Copy link
Contributor

It seems it happens when the Mono runtime creates a default OutOfMemoryException instance very early in the startup sequence, to stash it for potential further use.

@lambdageek thinks it might have to do with an old issue when the compiler or assembler output Thumb instructions instead of non-Thumb and the runtime didn't know how to process them.

@grendello
Copy link
Contributor

@jeromelaban would you be able to test the app without AOT enabled? Just to see if it crashes then.

@jeromelaban
Copy link
Author

@grendello the application works properly without AOT.

@grendello
Copy link
Contributor

@jeromelaban thanks, it most likely confirms @lambdageek's theory

@grendello
Copy link
Contributor

@jeromelaban so, we already fixed the issue in e1f2198, you would have to update to XA 17.3 to get the fix though.

@jeromelaban
Copy link
Author

@grendello Thanks for the update. Would you know when (or for which VS release) is it slated to be released?

@grendello
Copy link
Contributor

@jeromelaban I think it's released for VS 2022 right now, you can also download the package here https://github.com/xamarin/xamarin-android#current

@jeromelaban
Copy link
Author

Ok, so if it's released (Hosted Agents are using 17.3.32825.248) it would mean that it's a different issue?

@grendello
Copy link
Contributor

@jeromelaban to be honest, I don't know what version of XA shipped with that version of VS - it should be XA 13 which contains the fix, but I can't tell from the manifest you linked to if this is the case

@grendello
Copy link
Contributor

According to the list of tags under the commit, v13.0.99.36 v13.0.99.18 v13.0.0.0 v12.3.99.95 v12.3.99.58 should have the fix

@grendello
Copy link
Contributor

I checked in VS 2022 17.3.0 Preview 5.0, and it contains XA 13.0.0.0

@grendello
Copy link
Contributor

@jeromelaban would you be able to obtain a binlog of the CI build? We would be able to check what arguments are passed to the native linker when AOT-ing

@jeromelaban
Copy link
Author

Of course, here's one: 7352-build.zip

@grendello
Copy link
Contributor

@jeromelaban I see your build enables LLVM - this will cause the AOT task to not pass the --no-relax flag to the linker, which will eventually cause the issue. Can you try disabling LLVM to see if this is really the case?

@jeromelaban
Copy link
Author

Sure! It'll take me a few hours, I'll let you know.

@jeromelaban
Copy link
Author

@grendello Indeed, without LLVM yet with Profiled AOT enabled, the build is working properly.

@grendello
Copy link
Contributor

@jeromelaban until #6901 is merged and released, you'll need to keep LLVM disabled. Glad that it works though :)

@grendello
Copy link
Contributor

@jeromelaban since we addressed the original problem, I will close the issue and we can revisit enabling LLVM once #6901 is merged and you can test with it.

@grendello grendello removed the need-attention A xamarin-android contributor needs to review label Sep 8, 2022
@salgiza
Copy link

salgiza commented Sep 8, 2022

FWIW, I discovered this thread after having the same problem on an existing pipeline, and I can confirm that disabling LLVM solved the issue.

@jeromelaban
Copy link
Author

jeromelaban commented Sep 8, 2022

It's also worth noting that disabling LLVM slightly increases the package size (in our cases at least).

@SamMonoRT
Copy link
Member

Android LLVM crashes might be fixed with dotnet/runtime#74991, dotnet/runtime#75261 and dotnet/runtime#74674 backported to release\7.0 -- these should be included in RC2

@Alex-Dobrynin
Copy link

I have the same error, but there is no mention about AOT or LLVM.
this is my device log
device log.txt

This only happens when I build using appcenter. when I build using VS 2022 my app works fine

@salgiza
Copy link

salgiza commented Sep 16, 2022

@Alex-Dobrynin Two things that you should check, just in case:

  • Does AppCenter use a different build configuration (e.g. you build using Debug and AppCenter using Release)? The EnableLLVM option is usually enabled for Release, but not for Debug.
  • Does AppCenter set the EnableLLVM param when compiling? (You can pass the parameter to msbuild to ignore what's in the csproj file). If it wasn't for this bug, EnableLLVM should be enabled for Release builds, so it wouldn't surprise me if AppCenter added some default params. to msbuild, and this was one of them.

@Alex-Dobrynin
Copy link

Alex-Dobrynin commented Sep 16, 2022

@salgiza this is my proj settings
image
VS 2022 17.3.4

appcenter uses the same config but it uses this version of XA
image

When I change proj settings target framework to 12 android and change in appcenter version of XA to 12.3 it works well

@salgiza
Copy link

salgiza commented Sep 16, 2022

@Alex-Dobrynin under "AOT Compilation", uncheck the "Use LLVM Optimizing Compiler" option. If it's the same bug that we've talked about in this thread, that's the option that caused the issue to appear.

@Alex-Dobrynin
Copy link

@salgiza then why built by VS it is working? LLVM is on

@salgiza
Copy link

salgiza commented Sep 19, 2022

@Alex-Dobrynin no idea, but it's worth giving it a shot. If it stills fails compiling after you disable that option, though, that would mean that, even though the resulting error is the same, you might have found a different bug.

@ghost ghost locked as resolved and limited conversation to collaborators Oct 19, 2022
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.
Projects
None yet
Development

No branches or pull requests

8 participants