runtime: Mono crashes with SEGV_ACCERR for P/Invoke in android Debug

This blocks migration from Xamarin to net6.0-android. Although it may not be Mono’s fault, it definitely requires help from Mono developers.

Configuration

A net6.0-andoid project using the Realm package. In DEBUG configuration, it crashes during initializing native interop for Realm. I tried different combinations, but it always works in Release and crashes in Debug.

Logcat crash information is like this:

03-25 15:43:08.219 27554 27554 F DEBUG   : Revision: '0'
03-25 15:43:08.219 27554 27554 F DEBUG   : ABI: 'arm64'
03-25 15:43:08.219 27554 27554 F DEBUG   : Timestamp: 2022-03-25 15:43:08+0800
03-25 15:43:08.219 27554 27554 F DEBUG   : pid: 27452, tid: 27452, name: sh.ppy.osulazer  >>> sh.ppy.osulazer <<<
03-25 15:43:08.219 27554 27554 F DEBUG   : uid: 10306
03-25 15:43:08.219 27554 27554 F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x7fe2fd9e58
03-25 15:43:08.219 27554 27554 F DEBUG   : Cause: stack pointer is not in a rw map; likely due to stack overflow.
03-25 15:43:08.219 27554 27554 F DEBUG   :     x0  b400007aa412a680  x1  0000000000000027  x2  0000007ab6316ff0  x3  0000007ab6317184
03-25 15:43:08.219 27554 27554 F DEBUG   :     x4  0000007ab6316ff7  x5  0000000000000000  x6  0000007fe2fda1f0  x7  0000000000000028
03-25 15:43:08.219 27554 27554 F DEBUG   :     x8  0000007fe2fda1e8  x9  0000000000000020  x10 0000007ab6316ff7  x11 0000007b473f4000
03-25 15:43:08.219 27554 27554 F DEBUG   :     x12 0000007a00000000  x13 0000007200000000  x14 b400007aabe891cb  x15 0000000000000000
03-25 15:43:08.219 27554 27554 F DEBUG   :     x16 0000007a565575f8  x17 0000007b45c6cac0  x18 0000007b47ba0000  x19 0000007fe2fda700
03-25 15:43:08.219 27554 27554 F DEBUG   :     x20 0000007fe2fdad28  x21 0000007fe2fdaa10  x22 0000000000000000  x23 b400007aa43e4128
03-25 15:43:08.219 27554 27554 F DEBUG   :     x24 0000007fe2fda690  x25 0000007fe2fda1f0  x26 b400007b46e75c00  x27 0000000000000000
03-25 15:43:08.219 27554 27554 F DEBUG   :     x28 b400007aa43e4128  x29 0000007fe2fda1b0
03-25 15:43:08.219 27554 27554 F DEBUG   :     lr  0000007a5647833c  sp  0000007fe2fd9e30  pc  0000007a5644eab8  pst 0000000060001000
03-25 15:43:08.438 27554 27554 F DEBUG   : backtrace:
03-25 15:43:08.438 27554 27554 F DEBUG   :       #00 pc 00000000001fcab8  /data/app/~~SR43Q_ShKUrpQr-l0MMVvw==/sh.ppy.osulazer-nKVduS9o3FcHY8FRRBMy7g==/lib/arm64/libmonosgen-2.0.so (BuildId: 7310e0da105e448374721a35c0841ba1673fb87a)
03-25 15:43:08.438 27554 27554 F DEBUG   :       #01 pc 0000000000226338  /data/app/~~SR43Q_ShKUrpQr-l0MMVvw==/sh.ppy.osulazer-nKVduS9o3FcHY8FRRBMy7g==/lib/arm64/libmonosgen-2.0.so (BuildId: 7310e0da105e448374721a35c0841ba1673fb87a)
03-25 15:43:08.438 27554 27554 F DEBUG   :       #02 pc 00000000001e8910  /data/app/~~SR43Q_ShKUrpQr-l0MMVvw==/sh.ppy.osulazer-nKVduS9o3FcHY8FRRBMy7g==/lib/arm64/libmonosgen-2.0.so (BuildId: 7310e0da105e448374721a35c0841ba1673fb87a)
03-25 15:43:08.438 27554 27554 F DEBUG   :       #03 pc 00000000001e9b8c  /data/app/~~SR43Q_ShKUrpQr-l0MMVvw==/sh.ppy.osulazer-nKVduS9o3FcHY8FRRBMy7g==/lib/arm64/libmonosgen-2.0.so (BuildId: 7310e0da105e448374721a35c0841ba1673fb87a)
03-25 15:43:08.438 27554 27554 F DEBUG   :       #04 pc 00000000001e96bc  /data/app/~~SR43Q_ShKUrpQr-l0MMVvw==/sh.ppy.osulazer-nKVduS9o3FcHY8FRRBMy7g==/lib/arm64/libmonosgen-2.0.so (BuildId: 7310e0da105e448374721a35c0841ba1673fb87a)
03-25 15:43:08.438 27554 27554 F DEBUG   :       #05 pc 00000000001e7e60  /data/app/~~SR43Q_ShKUrpQr-l0MMVvw==/sh.ppy.osulazer-nKVduS9o3FcHY8FRRBMy7g==/lib/arm64/libmonosgen-2.0.so (BuildId: 7310e0da105e448374721a35c0841ba1673fb87a)
03-25 15:43:08.438 27554 27554 F DEBUG   :       #06 pc 0000000000076788  /data/app/~~SR43Q_ShKUrpQr-l0MMVvw==/sh.ppy.osulazer-nKVduS9o3FcHY8FRRBMy7g==/lib/arm64/libmonosgen-2.0.so (mono_method_get_last_managed+60) (BuildId: 7310e0da105e448374721a35c0841ba1673fb87a)
03-25 15:43:08.438 27554 27554 F DEBUG   :       #07 pc 0000000000058bb4  /data/app/~~SR43Q_ShKUrpQr-l0MMVvw==/sh.ppy.osulazer-nKVduS9o3FcHY8FRRBMy7g==/lib/arm64/libmonosgen-2.0.so (BuildId: 7310e0da105e448374721a35c0841ba1673fb87a)
03-25 15:43:08.438 27554 27554 F DEBUG   :       #08 pc 000000000006b608  /data/app/~~SR43Q_ShKUrpQr-l0MMVvw==/sh.ppy.osulazer-nKVduS9o3FcHY8FRRBMy7g==/lib/arm64/libmonosgen-2.0.so (BuildId: 7310e0da105e448374721a35c0841ba1673fb87a)
03-25 15:43:08.438 27554 27554 F DEBUG   :       #09 pc 000000000001a0c4  <anonymous:7ab62fd000>

The patterns realm is doing P/Invoke can be found here.

Build Realm is quite complicated, and it has only netstandard configuration. Is there any thing obviously wrong?

It is likely not a stack overflow, as it also crashes in a simpler project.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

I think it’s probably gone, let me confirm later today.