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

Crash on android aarch64 (Using Unity il2cpp) #2914

Open
Arlen-LT opened this issue Nov 30, 2023 · 1 comment
Open

Crash on android aarch64 (Using Unity il2cpp) #2914

Arlen-LT opened this issue Nov 30, 2023 · 1 comment

Comments

@Arlen-LT
Copy link

Version: 13.0.2(com.unity.nuget.newtonsoft-json@3.2)

Frequency: rarely

Description:

I think the crash is resulted by both Newtonsoft.json and il2cpp, maybe without il2cpp, this code can also throw some exception but can be handle by catch exception.

Here's the log:

Operating system: Android
                  0.0.0 Linux 4.19.157+ #1 SMP PREEMPT Fri Nov 10 04:11:04 PST 2023 aarch64
CPU: arm64
     8 CPUs

GPU: UNKNOWN

Crash reason:  SIGSEGV /SEGV_MAPERR
Crash address: 0x132
Process uptime: not available

Thread 77 (crashed)
 0  [libil2cpp.so]!il2cpp::vm::Class::Init(Il2CppClass*) [Class.cpp : 1548 + 0x0]
     x0 = 0x0000000000000000    x1 = 0x0000000000000001
     x2 = 0x0000000000000000    x3 = 0x0000000000000000
     x4 = 0x0000007205b690fa    x5 = 0xb40000706d654e05
     x6 = 0x707974206e6f2027    x7 = 0x272065707974206e
     x8 = 0x00000000fffffff1    x9 = 0x00000000ffffffff
    x10 = 0x0000000000000002   x11 = 0x0000000000000080
    x12 = 0x0005800000000000   x13 = 0x0000000000000001
    x14 = 0x0000000000000006   x15 = 0x0000007320ab6cc0
    x16 = 0x0000007206543560   x17 = 0x0000007320b162f0
    x18 = 0x000000705cafe000   x19 = 0x0000007270b3a110
    x20 = 0xb40000713df98420   x21 = 0x0000000000000000
    x22 = 0x0000000000000000   x23 = 0x0000000000000000
    x24 = 0x000000007fffffff   x25 = 0x000000720671fb88
    x26 = 0x000000727222da00   x27 = 0x000000727209ccf0
    x28 = 0x000000720674d270    fp = 0x00000072067255f8
     lr = 0x0000007203abe2d8    sp = 0x0000007270b3a030
     pc = 0x0000007203b19454
    Found by: given as instruction pointer in context
 1  [libil2cpp.so]!il2cpp::vm::Type::GetNameInternal(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >&, Il2CppType const*, Il2CppTypeNameFormat, bool) [Type.cpp : 683 + 0x0]
    x19 = 0x0000007270b3a110   x20 = 0xb40000713df98420
    x21 = 0x0000000000000000   x22 = 0x0000000000000000
    x23 = 0x0000000000000000   x24 = 0x000000007fffffff
    x25 = 0x000000720671fb88   x26 = 0x000000727222da00
    x27 = 0x000000727209ccf0   x28 = 0x000000720674d270
     fp = 0x00000072067255f8    sp = 0x0000007270b3a060
     pc = 0x0000007203abe2d8
    Found by: call frame info
 2  [libil2cpp.so]!il2cpp::vm::Type::GetName(Il2CppType const*, Il2CppTypeNameFormat) [Type.cpp : 772 + 0x8]
    x19 = 0x0000007270b3a110   x20 = 0x00000072003e2761
    x21 = 0xb40000706d8687a8   x22 = 0x000000727222da00
    x23 = 0x0000000000000000   x24 = 0x000000007fffffff
    x25 = 0x000000720671fb88   x26 = 0x000000727222da00
    x27 = 0x000000727209ccf0   x28 = 0x000000720674d270
     fp = 0x00000072067255f8    sp = 0x0000007270b3a0f0
     pc = 0x0000007203abe724
    Found by: call frame info
 3  [libil2cpp.so]!il2cpp::vm::RaiseExceptionForNotFoundInterface(Il2CppClass const*, Il2CppClass const*, unsigned short) [ClassInlines.cpp : 50 + 0xc]
    x19 = 0x0000007270b3a110   x20 = 0x00000072003e2761
    x21 = 0xb40000706d8687a8   x22 = 0x000000727222da00
    x23 = 0x0000000000000000   x24 = 0x000000007fffffff
    x25 = 0x000000720671fb88   x26 = 0x000000727222da00
    x27 = 0x000000727209ccf0   x28 = 0x000000720674d270
     fp = 0x00000072067255f8    sp = 0x0000007270b3a110
     pc = 0x0000007203ad9ab4
    Found by: call frame info
 4  [libil2cpp.so]!il2cpp::vm::ClassInlines::GetInterfaceInvokeDataFromVTableSlowPath(Il2CppObject*, Il2CppClass const*, unsigned short) [ClassInlines.cpp : 98 + 0xc]
    x19 = 0x0000000000000000   x20 = 0xb40000706d8687a8
    x21 = 0xb40000713df98400   x22 = 0x000000727222da00
    x23 = 0x0000000000000000   x24 = 0x000000007fffffff
    x25 = 0x000000720671fb88   x26 = 0x000000727222da00
    x27 = 0x000000727209ccf0   x28 = 0x000000720674d270
     fp = 0x00000072067255f8    sp = 0x0000007270b3a230
     pc = 0x0000007203ad99a8
    Found by: call frame info
 5  [libil2cpp.so]!WhereEnumerableIterator_1_MoveNext_m7F8C3A8E4FC2835971FF35C1F4C51A061483BEDD_gshared [ClassInlines.h : 56 + 0x8]
    x19 = 0x0000007272152740   x20 = 0xb40000706d9a29b0
    x21 = 0x000000727222da00   x22 = 0x0000007206713228
    x23 = 0x0000007206713160   x24 = 0x000000007fffffff
    x25 = 0x000000720671fb88   x26 = 0x000000727222da00
    x27 = 0x000000727209ccf0   x28 = 0x000000720674d270
     fp = 0x00000072067255f8    sp = 0x0000007270b3a260
     pc = 0x00000072052c3b34
    Found by: call frame info
 6  [libil2cpp.so]!Enumerable_Count_TisRuntimeObject_mA9FCB8ECCFE8FABC5AA2F8D46F82ACD52279930B_gshared [GenericMethods__15.cpp : 142 + 0x4]
    x19 = 0x0000007272152740   x20 = 0x0000000000000000
    x21 = 0x0000007206744158   x22 = 0x0000007206713228
    x23 = 0x0000007206713160   x24 = 0x000000007fffffff
    x25 = 0x000000720671fb88   x26 = 0x000000727222da00
    x27 = 0x000000727209ccf0   x28 = 0x000000720674d270
     fp = 0x00000072067255f8    sp = 0x0000007270b3a290
     pc = 0x00000072042ec89c
    Found by: call frame info
 7  [libil2cpp.so]!StringUtils_ForgivingCaseSensitiveFind_TisRuntimeObject_m195410DEDDDC8B5F920825627EA95985B002B371_gshared [GenericMethods__18.cpp : 30159 + 0x0]
    x19 = 0xb40000706d98d4c0   x20 = 0x000000727222da00
    x21 = 0x0000007271ed4c00   x22 = 0x0000007272152740
    x23 = 0x000000727209ccf0   x24 = 0x0000007271ed4c10
    x25 = 0x000000720671fb88   x26 = 0x000000727222da00
    x27 = 0x000000727209ccf0   x28 = 0x000000720674d270
     fp = 0x00000072067255f8    sp = 0x0000007270b3a2d0
     pc = 0x0000007204516cbc
    Found by: call frame info
 8  [libil2cpp.so]!JsonSerializerInternalReader_CreateObjectUsingCreatorWithParameters_m1C26F454DDB083972F36EBE27C1C3C6361FF21A3 [Newtonsoft.Json__2.cpp : 6546 + 0x8]
    x19 = 0x00000072724bee10   x20 = 0x00000072720a8d10
    x21 = 0x0000000000000000   x22 = 0x0000007271ed4cc0
    x23 = 0x0000007272135100   x24 = 0x0000000000000001
    x25 = 0x000000720671fb88   x26 = 0x000000727222da00
    x27 = 0x000000727209ccf0   x28 = 0x000000720674d270
     fp = 0x00000072067255f8    sp = 0x0000007270b3a310
     pc = 0x0000007205250d50
    Found by: call frame info
 9  [libil2cpp.so]!JsonSerializerInternalReader_CreateObject_mD7F8E57151B7EFE0B4A883F21D71B9B7A6AB5662 [Newtonsoft.Json__2.cpp : 16922 + 0x14]
    x19 = 0x00000070d23379a0   x20 = 0x0000000000000000
    x21 = 0x0000000000000000   x22 = 0x00000072721527c0
    x23 = 0x00000072720a8d10   x24 = 0x0000007272093700
    x25 = 0x0000000000000000   x26 = 0x00000072067d9000
    x27 = 0x0000000000000002   x28 = 0x00000072067de000
     fp = 0x0000007270b3a800    sp = 0x0000007270b3a3f0
     pc = 0x000000720524a674
    Found by: call frame info
10  [libil2cpp.so]!JsonSerializerInternalReader_Deserialize_m37E61DFB1A0016D0CCCFCF33D489BD079BD65EF3 [Newtonsoft.Json__2.cpp : 15455 + 0x20]
    x19 = 0x00000072721527c0   x20 = 0x00000070d23379a0
    x21 = 0x00000072720a8d10   x22 = 0x0000000000000001
    x23 = 0x0000007272093700   x24 = 0x0000000000000000
    x25 = 0x0000007206712520   x26 = 0x00000072067138a0
    x27 = 0x0000000000000002   x28 = 0x00000072067de000
     fp = 0x0000007270b3a800    sp = 0x0000007270b3a4a0
     pc = 0x0000007205248db8
    Found by: call frame info
11  [libil2cpp.so]!JsonSerializer_DeserializeInternal_m218BEE555BD1AB9149BAB16A323BFE0F038368AE [Newtonsoft.Json.cpp : 14249 + 0x10]
    x19 = 0x00000070d23379a0   x20 = 0x000000726487f870
    x21 = 0x0000007272093700   x22 = 0x00000072721527c0
    x23 = 0x0000000000000000   x24 = 0x00000072067138a8
    x25 = 0x0000007206712520   x26 = 0x00000072067138a0
    x27 = 0x0000000000000002   x28 = 0x00000072067de000
     fp = 0x0000007270b3a800    sp = 0x0000007270b3a4f0
     pc = 0x0000007204eab794
    Found by: call frame info
12  [libil2cpp.so]!JsonConvert_DeserializeObject_m8601FB6D35A0E41575940296CCCFD27B97EA97A2 [Newtonsoft.Json.cpp : 97 + 0xc]
    x19 = 0x00000070d23379a0   x20 = 0x0000007272093700
    x21 = 0x000000726487f870   x22 = 0x0000007271ed4cf0
    x23 = 0x0000007206713160   x24 = 0x000000720670fd40
    x25 = 0x0000007206712520   x26 = 0x00000072067138a0
    x27 = 0x0000000000000002   x28 = 0x00000072067de000
     fp = 0x0000007270b3a800    sp = 0x0000007270b3a560
     pc = 0x0000007204ea45c4
    Found by: call frame info
13  [libil2cpp.so]!JsonConvert_DeserializeObject_TisRuntimeObject_mA0A545A7C0835F2CCABDCD416530F65994B8EFBA_gshared [GenericMethods__16.cpp : 28666 + 0x10]
    x19 = 0xb40000706d7db4e0   x20 = 0x0000000000000000
    x21 = 0x00000072724bc6c0   x22 = 0x0000007272093700
    x23 = 0x0000007206714168   x24 = 0x000000720670fd40
    x25 = 0x0000007206712520   x26 = 0x00000072067138a0
    x27 = 0x0000000000000002   x28 = 0x00000072067de000
     fp = 0x0000007270b3a800    sp = 0x0000007270b3a590
     pc = 0x0000007205464d4c
    Found by: call frame info
14  [libil2cpp.so]!mE48AA053B0037F3B9E4184DB6A56B31F292794DF [Assembly-CSharp__2.cpp : 11411 + 0x4]
    x19 = 0x00000072724bc6c0   x20 = 0x00000072067482b0
    x21 = 0x0000007206714168   x22 = 0x0000007206731470
    x23 = 0x00000072067161c8   x24 = 0x000000720670fd40
    x25 = 0x0000007206712520   x26 = 0x00000072067138a0
    x27 = 0x0000000000000002   x28 = 0x00000072067de000
     fp = 0x0000007270b3a800    sp = 0x0000007270b3a5c0
     pc = 0x00000072046cc310
    Found by: call frame info
15  [libil2cpp.so]!U3CU3Ec__DisplayClass12_0_U3C0_mD9BA029AFDBBAB632993AE54F35B28D34AE92345 [Assembly-CSharp__2.cpp : 29763 + 0x4]
    x19 = 0x00000072720a7d90   x20 = 0x00000070d23330c0
    x21 = 0x0000007271de5cc0   x22 = 0x0000007272183600
    x23 = 0x00000072067161c8   x24 = 0x000000720670fd40
    x25 = 0x0000007206712520   x26 = 0x00000072067138a0
    x27 = 0x0000000000000002   x28 = 0x00000072067de000
     fp = 0x0000007270b3a800    sp = 0x0000007270b3a5f0
     pc = 0x00000072046cd958
    Found by: call frame info
16  [libil2cpp.so]!Task_Execute_m4FBCBCE932B924AD239A2448AED5708B6D14A7F1 [mscorlib__9.cpp : 26 + 0x0]
    x19 = 0x00000072721835a0   x20 = 0x00000070d2339870
    x21 = 0x0000000000000001   x22 = 0x00000072724bef50
    x23 = 0x0000007271e4de40   x24 = 0x0000000000000000
    x25 = 0x0000007206712520   x26 = 0x00000072067138a0
    x27 = 0x0000000000000002   x28 = 0x00000072067de000
     fp = 0x0000007270b3a800    sp = 0x0000007270b3a630
     pc = 0x000000720559a1dc
    Found by: call frame info
17  [libil2cpp.so]!ExecutionContext_RunInternal_mC37E85D6FC972DF219A00FE1EE34329D1D63CC94 [mscorlib__8.cpp : 34448 + 0x4]
    x19 = 0x00000072721835a0   x20 = 0x00000070d2339870
    x21 = 0x0000000000000001   x22 = 0x00000072724bef50
    x23 = 0x0000007271e4de40   x24 = 0x0000000000000000
    x25 = 0x0000007206712520   x26 = 0x00000072067138a0
    x27 = 0x0000000000000002   x28 = 0x00000072067de000
     fp = 0x0000007270b3a800    sp = 0x0000007270b3a650
     pc = 0x000000720484ba5c
    Found by: call frame info
18  [libil2cpp.so]!Task_ExecuteWithThreadLocal_mD3F4E7ADBBC473EAF7C24B3A785EBB452D6A76BE [mscorlib__9.cpp : 22265 + 0x14]
    x19 = 0x00000070d2325660   x20 = 0x0000000000000000
    x21 = 0x00000072721835a0   x22 = 0x00000072724bef50
    x23 = 0x00000070d2339870   x24 = 0x0000007206717010
    x25 = 0x0000007206717318   x26 = 0x00000072067138a0
    x27 = 0x0000000000000002   x28 = 0x00000072067de000
     fp = 0x0000007270b3a800    sp = 0x0000007270b3a6d0
     pc = 0x000000720559a5c8
    Found by: call frame info
19  [libil2cpp.so]!Task_ExecuteEntry_m735BD89474854D6EAA2ED929D6765AF1B4AEDCDF [mscorlib__9.cpp : 18917 + 0x4]
    x19 = 0x00000072721835a0   x20 = 0x0000007206717010
    x21 = 0x00000072067da000   x22 = 0x00000072721835a0
    x23 = 0x0000007270b3a7b0   x24 = 0x0000007270b3acc0
    x25 = 0x0000007206717318   x26 = 0x00000072067138a0
    x27 = 0x0000000000000002   x28 = 0x00000072067de000
     fp = 0x0000007270b3a800    sp = 0x0000007270b3a710
     pc = 0x000000720559a484
    Found by: call frame info
20  [libil2cpp.so]!ThreadPoolWorkQueue_Dispatch_mEAAC936B3756DAA856BA3A4D976A98A3184CDC87 [mscorlib__9.cpp : 169 + 0x4]
    x19 = 0x00000070d845ec30   x20 = 0x0000000002fd8112
    x21 = 0x00000070d84f3210   x22 = 0x00000072721835a0
    x23 = 0x0000007270b3a7b0   x24 = 0x0000007270b3acc0
    x25 = 0x0000007206717318   x26 = 0x00000072067138a0
    x27 = 0x0000000000000002   x28 = 0x00000072067de000
     fp = 0x0000007270b3a800    sp = 0x0000007270b3a740
     pc = 0x000000720558fd58
    Found by: call frame info
21  [libil2cpp.so]!RuntimeInvoker_FalseByte_t94D9231AC217BE4D2E004C4CD32DF6D099EA41A3(void (*)(), MethodInfo const*, void*, void**, void*) [Il2CppInvokerTable.cpp : 125462 + 0x0]
    x19 = 0x0000007270b3a7b0   x20 = 0xb40000726d119d80
    x21 = 0x0000000000000000   x22 = 0xb40000726d22ca00
    x23 = 0x0000007270b3a7b0   x24 = 0x0000007270b3acc0
    x25 = 0xb40000706fd55088   x26 = 0xb4000070d3676f00
    x27 = 0x0000000000000002   x28 = 0x00000072067de000
     fp = 0x0000007270b3a800    sp = 0x0000007270b3a7a0
     pc = 0x0000007203a2a574
    Found by: call frame info
22  [libil2cpp.so]!il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**) [Runtime.cpp : 588 + 0x10]
    x19 = 0x0000000000000000   x20 = 0xb40000726d119d80
    x21 = 0x0000000000000000   x22 = 0xb40000726d22ca00
    x23 = 0x0000007270b3a7b0   x24 = 0x0000007270b3acc0
    x25 = 0xb40000706fd55088   x26 = 0xb4000070d3676f00
    x27 = 0x0000000000000002   x28 = 0x00000072067de000
     fp = 0x0000007270b3a800    sp = 0x0000007270b3a7b0
     pc = 0x0000007203b0ec30
    Found by: call frame info
23  [libil2cpp.so]!worker_thread(void*) [ThreadPoolWorkerThread.cpp : 250 + 0x8]
    x19 = 0xb4000070d3676f00   x20 = 0x0000000000000000
    x21 = 0x0000007269ed7390   x22 = 0xb4000070d18fd590
    x23 = 0x00000072067de000   x24 = 0x00000072067de308
    x25 = 0xb40000706fd55088   x26 = 0xb4000070d3676f00
    x27 = 0x0000000000000002   x28 = 0x00000072067de000
     fp = 0x0000007270b3a920    sp = 0x0000007270b3a810
     pc = 0x0000007203afe2e8
    Found by: call frame info
24  [libil2cpp.so]!il2cpp::vm::ThreadStart(void*) [Thread.cpp : 697 + 0x0]
    x19 = 0x0000007269ed5960   x20 = 0x0000007269ed5960
    x21 = 0xb40000706fc62f40   x22 = 0x0000007203b6c934
    x23 = 0x00000000000064e0   x24 = 0x0000007270b3a970
    x25 = 0x0000007270b3aa0c   x26 = 0x0000007270b3acb8
    x27 = 0x00000070d0162cc0   x28 = 0x00000000000fe000
     fp = 0x0000007270b3a920    sp = 0x0000007270b3a8b0
     pc = 0x0000007203b6c974
    Found by: call frame info
25  [libil2cpp.so]!il2cpp::os::Thread::RunWrapper(void*) [Thread.cpp : 201 + 0x0]
    x19 = 0xb40000706fa29c40   x20 = 0x0000007269ed5960
    x21 = 0xb40000706fc62f40   x22 = 0x0000007203b6c934
    x23 = 0x00000000000064e0   x24 = 0x0000007270b3a970
    x25 = 0x0000007270b3aa0c   x26 = 0x0000007270b3acb8
    x27 = 0x00000070d0162cc0   x28 = 0x00000000000fe000
     fp = 0x0000007270b3a920    sp = 0x0000007270b3a8e0
     pc = 0x0000007203b3a41c
    Found by: call frame info
26  [libil2cpp.so]!il2cpp::os::ThreadImpl::ThreadStartWrapper(void*) [ThreadImpl.cpp : 125 + 0x0]
    x19 = 0xb4000070d1c77c10   x20 = 0x0000007320b6f154
    x21 = 0x0000007270b3a970   x22 = 0x000000000000655a
    x23 = 0x00000000000064e0   x24 = 0x0000007270b3a970
    x25 = 0x0000007270b3aa0c   x26 = 0x0000007270b3acb8
    x27 = 0x00000070d0162cc0   x28 = 0x00000000000fe000
     fp = 0x0000007270b3a920    sp = 0x0000007270b3a910
     pc = 0x0000007203b61990
    Found by: call frame info
27  [libc.so] + 0xdf1d8
    x19 = 0x0000007270b3a970   x20 = 0x0000007320b6f154
    x21 = 0x0000007270b3a970   x22 = 0x000000000000655a
    x23 = 0x00000000000064e0   x24 = 0x0000007270b3a970
    x25 = 0x0000007270b3aa0c   x26 = 0x0000007270b3acb8
    x27 = 0x00000070d0162cc0   x28 = 0x00000000000fe000
     fp = 0x0000007270b3a920    sp = 0x0000007270b3a920
     pc = 0x0000007320b6f1dc
    Found by: call frame info

Source/destination JSON

{"version":"1.0", "method":"SomeMethod","arguments":{"host":"127.0.0.1","username":"test","password":"test"},"req_id":"xxx","req_time":"xxx"}

Expected behavior

Not Crash

Steps to reproduce

[JsonObject(MemberSerialization.OptIn)]
public class Request<T>
{
    [JsonProperty(Order = -3)]
    private string version;
    [JsonProperty(Order = -2)]
    private string method;
    [JsonProperty(Order = -1)]
    public T arguments;
    [JsonProperty]
    private readonly string req_id;
    [JsonProperty]
    public readonly DateTime req_time;

    public Request(string version, T arg)
    {
        this.version = version;
        this.method = typeof(T).FullName;
        this.arguments = arg;
        this.req_id = Guid.NewGuid().ToString();
        this.req_time = DateTime.Now;
    }

    public string ToJson()
    {
        return JsonConvert.SerializeObject(this);
    }
}

public struct SomeArgs
{
    public string host;
    public string username;
    public string password;
}

int Foo(Request<SomeArgs> req)
{
    Task.Run(delegate
    {
            var des = JsonConvert.DeserializeObject<Request<SomeArgs>>(req.ToJson());
            des.arguments.username = /* Some operation */
            return des.ToJson();
    });
    return 0;
}
@elgonzo
Copy link

elgonzo commented Nov 30, 2023

While i am only a user and not a maintainer of Newtonsoft.Json (but moving away from it in favour of STJ), your problem is essentially with the code il2cpp produces. Therefore, you should contact the il2cpp folks and file an issue with them and listen to what they have to say about what you could/should do regarding using il2cpp on a project utilizing Newtonsoft.Json. There is/was a custom 3rd-party modification of Newtonsoft.Json somewhere on github that claims to be compatible with il2cpp, but i don't know it and can't say anything about it. (Also, it will be unlikely to get support and help for a 3rd-party modification of Newtonsoft.Json here in the issue tracker of the official Newtonsoft.Json library.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants