After updating to Unity 2020 (from 2019) we experienced this new il2cpp crash and I’ll just post it here for visibility. I saw this stack trace in the Google Play Console, so I have no actual way to reproduce this in a Unity project to submit as a bug report. It also affects only a small subset of users, but for those users it crashed a significant amount of times driving our crash rate through the roof.
I just fixed it by not calling Array.IndexOf() and that seems to fix it in case someone else sees this bug. I suppose it’s super rare as you have to use threading and enums in a very specific way.
Error:
null pointer dereference
Hope that helps, also Unity please fix. Current editor version is 2020.3.39f1
This is not a problem we have seen before, thanks for reporting it! Even though you cannot provide a project, there might be enough information here for us to reproduce and correct the issue. Can you submit a bug report anyway? Once it is submitted, please let me know the bug report number. I’ll work with our QA team to get it processed.
@JoshPeterson the bug report has been submitted, took a bit of time. I’ve included our code samples as best I could, but it’s a bit tricky in an empty project.
Report: IN-18293 - [IL2CPP][Android] Crash calling Array.IndexOf on array of enums on the thread pool
I’ve also since had more time to monitor our crashes and the work around is holding up reducing the amount of times this specific stack trace is shown down to zero.
We got almost same crash from GooglePlay, after upgrade from 2019.4.35 to 2021.3.12. have tried .net framework and .net standard 2.1, it still occurs. not 100% reproducible. the stack is like this:
Fatal Exception: Tombstone : Version '2021.3.12f1 (8af3c3e441b1)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'arm64-v8a'
Build fingerprint:
Revision: '20'
ABI: 'arm64'
Timestamp: 2022-10-27 20:28:17-0500
pid: 3417, tid: 29690, name: Thread-26
uid: 10054
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x11c
Cause: null pointer dereference
x0 0000000000000000 x1 0000006b038f2548 x2 0000000000000000 x3 0000000000000010
x4 0000000000000000 x5 0000006b038f25fc x6 0000006f678db440 x7 0000007067932a30
x8 0000000000000000 x9 00000000ffffffff x10 000000000b4322e8 x11 00000000179a9800
x12 0000ffff00000eff x13 0000000046bf7fca x14 00114dd6e8f45adb x15 0000000034155555
x16 0000006e2f9bab50 x17 000000720163f02c x18 0000006b02f84000 x19 0000006b038f2548
x20 0000000000000000 x21 0000006e2f1047ac x22 0000006e2f1047b2 x23 0000000000000000
x24 0000006af6b7cd80 x25 0000006e2fb37ac0 x26 0000006e2fb2bed8 x27 0000000000000000
x28 0000006b038f2678 x29 0000000000000000
sp 0000006b038f24d0 lr 0000006e2d8910b8 pc 0000006e2d8910f0
#00 pc il2cpp::vm::Class::SetupMethods(Il2CppClass*) at unityLibrary/src/main/Il2CppOutputProject/IL2CPP/libil2cpp/vm/Class.cpp:1212 libil2cpp.so (il2cpp::vm::Class::SetupMethods(Il2CppClass*) [Class.cpp:1212])
#01 pc il2cpp::vm::Class::GetMethods(Il2CppClass*, void**) at unityLibrary/src/main/Il2CppOutputProject/IL2CPP/libil2cpp/vm/Class.cpp:427 libil2cpp.so (il2cpp::vm::Class::GetMethods(Il2CppClass*, void**) [Class.cpp:427])
#02 pc il2cpp::icalls::mscorlib::System::RuntimeType::GetConstructors_native(Il2CppReflectionRuntimeType*, int) at unityLibrary/src/main/Il2CppOutputProject/IL2CPP/libil2cpp/icalls/mscorlib/System/RuntimeType.cpp:317 libil2cpp.so (il2cpp::icalls::mscorlib::System::RuntimeType::GetConstructors_native(Il2CppReflectionRuntimeType*, int) [RuntimeType.cpp:317])
#03 pc RuntimeType_GetConstructors_native_m5FF45352FBB9F8F4DB176D36B393BFC43DB000FD at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/mscorlib6.cpp:33674
(inlined by) RuntimeType_GetConstructors_internal_m26A9A5C3281D0B2FC37881B6C644D7160543BD9F at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/mscorlib6.cpp:33701 libil2cpp.so
#04 pc RuntimeType_GetConstructorCandidates_mB1CAAF37CC4F1237F958EFC376BEF2BAE06B1F5A at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/mscorlib6.cpp:26253 libil2cpp.so
#05 pc RuntimeType_GetConstructors_mD7BC033DCFBD7559795E0129101AC365E4457C9F at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/mscorlib6.cpp:26800 libil2cpp.so
#06 pc VirtualFuncInvoker1<ConstructorInfoU5BU5D_t515A0B944728842263B6033C9A62F6392C3BCD8A*, int>::Invoke(unsigned short, Il2CppObject*, int) at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/mscorlib6.cpp:60
(inlined by) RuntimeType_GetDefaultConstructor_mBE566FF8A201353FF9BF5417C88EACF48C0EC462 at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/mscorlib6.cpp:31790 libil2cpp.so
#07 pc RuntimeType_CreateInstanceForAnotherGenericParameter_m5AD0AF8C5D092750500FF193E17F311C59A6D066 at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/mscorlib6.cpp:33517 libil2cpp.so
#08 pc EqualityComparer_1_CreateComparer_mE9DC7CAF58EE3B2D235851CCFF895CD1C51F3E6B_gshared at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/Generics20.cpp:? libil2cpp.so (EqualityComparer_1_CreateComparer_mE9DC7CAF58EE3B2D235851CCFF895CD1C51F3E6B_gshared [Generics20.cpp:12155])
#09 pc EqualityComparer_1_get_Default_m337E4360DF25127CED0E5DEC4827A905E8EBA5E0_gshared at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/Generics20.cpp:12052 libil2cpp.so (EqualityComparer_1_get_Default_m337E4360DF25127CED0E5DEC4827A905E8EBA5E0_gshared [Generics20.cpp:12052])
#10 pc LinkedList_1_Find_m9B15B8FABDEC1927C8A1E03C9572553635B9D5F2_gshared at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/Generics29.cpp:33979 libil2cpp.so (LinkedList_1_Find_m9B15B8FABDEC1927C8A1E03C9572553635B9D5F2_gshared [Generics29.cpp:33979])
#11 pc LinkedList_1_Remove_m0A449A505C33965CDA0244A163E34BBDE6AD6227_gshared at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/Generics29.cpp:34086 libil2cpp.so (LinkedList_1_Remove_m0A449A505C33965CDA0244A163E34BBDE6AD6227_gshared [Generics29.cpp:34086])
#12 pc LinkedList_1_Remove_m69152156C2A2583899D0EE535ED42E984AD7AFC7(LinkedList_1_t722196FC41A6FF03487667AADD82ED07E9D75F79*, ValueTuple_2_tD2DC48356F46A400B0222C822B85124F5184C03F, MethodInfo const*) at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/System7.cpp:6771
(inlined by) U3CRunSchedulerU3Ed__32_MoveNext_mA08FEA7A8A1F2C0B268B36676228CFDF37B007C1 at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/System7.cpp:17541 libil2cpp.so
#13 pc ContextCallback_Invoke_m872CCCD40428B88C2612772491BE5157895B5F61_inline(ContextCallback_tE8AFBDBFCC040FDA8DA8C1EEFE9BD66B16BDA007*, Il2CppObject*, MethodInfo const*) at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/mscorlib8.cpp:32972
(inlined by) ExecutionContext_RunInternal_mC37E85D6FC972DF219A00FE1EE34329D1D63CC94 at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/mscorlib8.cpp:26652 libil2cpp.so
#14 pc MoveNextRunner_Run_m86395F123FB453F2B5FF89CE1E98532F7426F9DE at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/mscorlib17.cpp:24484 libil2cpp.so
#15 pc Action_Invoke_m7126A54DACA72B845424072887B5F3A51FC3808E_inline(Action_tD00B0A84D7945E50C2DFFC28EFEE6ED44ED2AD07*, MethodInfo const*) at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/mscorlib9.cpp:34061
(inlined by) AwaitTaskContinuation_RunOrScheduleAction_mAB1E447337DDFFE6824A12BBEDE6324AA2823800 at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/mscorlib9.cpp:20876 libil2cpp.so
#16 pc Task_FinishContinuations_m21B540B556CDABD76F5985DF83079F7F30C78174 at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/mscorlib9.cpp:16928 libil2cpp.so
#17 pc Task_1_TrySetResult_m2EE766FD3F76F4824990F4A93ED1F7253ECE014C_gshared at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/Generics51.cpp:4561 libil2cpp.so (Task_1_TrySetResult_m2EE766FD3F76F4824990F4A93ED1F7253ECE014C_gshared [Generics51.cpp:4561])
#18 pc Task_1_TrySetResult_m8A4CF9B259E5B700C5F6BCAEA521DAFA4389FFE6(Task_1_t65B0CFA55427D8F65292A36D9BE1B7C5D949EE11*, Task_t751C4CC3ECD055BABA8A0B6A5DFBB4283DCA8572*, MethodInfo const*) at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/mscorlib9.cpp:5259
(inlined by) CompleteOnInvokePromise_Invoke_mF5F31F1D9FD06E73EA1239A32B3B14A3D925543E at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/mscorlib9.cpp:21999 libil2cpp.so
#19 pc InterfaceActionInvoker0::Invoke(unsigned short, Il2CppClass*, Il2CppObject*) at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/mscorlib8.cpp:124
(inlined by) ThreadPoolWorkQueue_Dispatch_mEAAC936B3756DAA856BA3A4D976A98A3184CDC87 at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/mscorlib8.cpp:31277 libil2cpp.so
#20 pc RuntimeInvoker_FalseByte_t94D9231AC217BE4D2E004C4CD32DF6D099EA41A3(void (*)(), MethodInfo const*, void*, void**, void*) at unityLibrary/src/main/Il2CppOutputProject/Source/il2cppOutput/Il2CppInvokerTable.cpp:98546 libil2cpp.so (RuntimeInvoker_FalseByte_t94D9231AC217BE4D2E004C4CD32DF6D099EA41A3(void (*)(), MethodInfo const*, void*, void**, void*) [Il2CppInvokerTable.cpp:98546])
#21 pc il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**) at unityLibrary/src/main/Il2CppOutputProject/IL2CPP/libil2cpp/vm/Runtime.cpp:577 libil2cpp.so (il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**) [Runtime.cpp:577])
#22 pc worker_thread(void*) at unityLibrary/src/main/Il2CppOutputProject/IL2CPP/libil2cpp/mono/ThreadPool/ThreadPoolWorkerThread.cpp:250 libil2cpp.so (worker_thread(void*) [ThreadPoolWorkerThread.cpp:250])
#23 pc il2cpp::vm::ThreadStart(void*) at unityLibrary/src/main/Il2CppOutputProject/IL2CPP/libil2cpp/vm/Thread.cpp:701 libil2cpp.so (il2cpp::vm::ThreadStart(void*) [Thread.cpp:701])
#24 pc il2cpp::os::Thread::RunWrapper(void*) at unityLibrary/src/main/Il2CppOutputProject/IL2CPP/libil2cpp/os/Thread.cpp:201 libil2cpp.so (il2cpp::os::Thread::RunWrapper(void*) [Thread.cpp:201])
#25 pc il2cpp::os::ThreadImpl::ThreadStartWrapper(void*) at unityLibrary/src/main/Il2CppOutputProject/IL2CPP/libil2cpp/os/Posix/ThreadImpl.cpp:125 libil2cpp.so (il2cpp::os::ThreadImpl::ThreadStartWrapper(void*) [ThreadImpl.cpp:125])
#26 pc 0xb6e94 libc.so (__pthread_start(void*) + 264)
#27 pc 0x534b0 libc.so (__start_thread + 68)
Since it’s from the namespace System, we don’t have workaround for it.
We use System.Net.HttpWebRequest only in a custom thread. wish these are helpful for tracking the issue.
It’s possible that it happens during shudown, we didn’t get report from players about crashes, it only appears in googleplay and firebase’s console. I’ll go check it, Thanks a lot
I am sorry I don’t. I tried but failed to reproduce it locally.
In the release of 2021.3.14, there is a fix “IL2CPP: Corrected handle enums declared inside a generic type. (UUM-612)”.
But the detail is not visible. I am wondering why some of the issues have no link. Do you have any ideas about it?
Unfortunately that bug report is not a public bug, so it does not have a public issue track link. However, the problematic case this fix corrects looks something like this:
class MyClassA<T> {
public enum MyEnum { A, B }
}
[MyAttribute(val = MyClassA<int>.MyEnum.B)]
class MyClassB {
...
}
Reproducing I am not sure, as when I create an empty project, install and configure IAP, UnityAds and PlayGamServices it doesn’t occur
For now I used a custom shader so I added those shaders to always include in graphics settings… I am running a build presently
I have “terminating with uncaught exception of type Il2CppExceptionWrapper - libc++abi: terminating with uncaught exception of type Il2CppExceptionWrapper” in this line
This might be a different issue. The error “terminating with uncaught exception of type Il2CppExceptionWrapper” means that a managed exception was thrown and not caught - so that could be a problem on the Unity side, or it could be an error in the managed code in the project.
Can you find details about the managed exception in the player log?
This issue is happened right after I get answer from the user about App Tracking Transparency with iOS 14 Advertising Support package 1.2 and before the code in the previous post. No matter what user’s answer is.
Environment:
iOS 16.2
iPhone XS Max
Unity 2021.3.16
Development Mode
Without Development Mode, I have no issue!
Log ends here:
2023-01-07 14:44:45.874364+0300 [2649:119173] AppTrackingTransparency framework already present
ATT iOS Support: Requesting...
AppTrackingTransparencyControl:RequestAuthorizationTracking()
UnityEngine.Events.UnityEvent:Invoke()
UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean)
UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents()
UnityEngine.EventSystems.StandaloneInputModule:Process()
-> applicationWillResignActive()
2023-01-07 14:44:54.768799+0300 [2649:119466] Result request tracking authorization : 3
libc++abi: terminating with uncaught exception of type Il2CppExceptionWrapper
terminating with uncaught exception of type Il2CppExceptionWrapper
(lldb)
For the 2nd installation with Dev Mode and cache with user’s answer, I have no issue - System Window Request of ATT doesn’t show (as planned).
Can you try this with script debugging enabled? Maybe also enable “break on exceptions” in the IDE. I’ve having trouble telling what is causing the exception from this stack trace, but maybe the debugger can help here.
@JoshPeterson
Hi, I encountered a similar issue recently and created a reproducible project. It can reproduce the crash on Windows and Android when using Unity 2020.3.42. The case number is IN-29059.
Callstack
(il2cpp::vm::Class::SetupMethods(Il2CppClass*) at C:\Program Files\Unity\Hub\Editor\2020.3.42f1\Editor\Data\il2cpp\libil2cpp\vm/Class.cpp:1185)
(il2cpp::vm::Class::GetMethods(Il2CppClass*, void**) at C:\Program Files\Unity\Hub\Editor\2020.3.42f1\Editor\Data\il2cpp\libil2cpp\vm/Class.cpp:407)
(il2cpp::icalls::mscorlib::System::MonoType::GetConstructors_internal(Il2CppReflectionType*, int, Il2CppReflectionType*) at C:\Program Files\Unity\Hub\Editor\2020.3.42f1\Editor\Data\il2cpp\libil2cpp\icalls\mscorlib\System/MonoType.cpp:322)
(il2cpp::icalls::mscorlib::System::RuntimeType::GetConstructors_native(Il2CppReflectionRuntimeType*, int) at C:\Program Files\Unity\Hub\Editor\2020.3.42f1\Editor\Data\il2cpp\libil2cpp\icalls\mscorlib\System/RuntimeType.cpp:186)
(RuntimeType_GetConstructors_native_m5CCF922D11092D8665306CB927C1948D436CA797 at D:\Projects\TestIL2CPPEnumCrash\Library\Il2cppBuildCache\Android\armeabi-v7a\il2cppOutput/mscorlib10.cpp:29887)
(RuntimeType_GetConstructorCandidates_m1AF80B6730AF93BA20B47C13DDBBF4EC3E79793F at D:\Projects\TestIL2CPPEnumCrash\Library\Il2cppBuildCache\Android\armeabi-v7a\il2cppOutput/mscorlib10.cpp:22483)
(RuntimeType_GetConstructors_m2372DD53472A92140806E6683A1CC248CE3378A5 at D:\Projects\TestIL2CPPEnumCrash\Library\Il2cppBuildCache\Android\armeabi-v7a\il2cppOutput/mscorlib10.cpp:23027)
(VirtFuncInvoker1<ConstructorInfoU5BU5D_t3AD132A16A05A15B043BE275A8822F1872770498*, int>::Invoke(unsigned short, Il2CppObject*, int) at D:\Projects\TestIL2CPPEnumCrash\Library\Il2cppBuildCache\Android\armeabi-v7a\il2cppOutput/mscorlib10.cpp:54)
(RuntimeType_CreateInstanceForAnotherGenericParameter_mD7DE72CEDD3346ADBEAC89754148FB806731C2BF at D:\Projects\TestIL2CPPEnumCrash\Library\Il2cppBuildCache\Android\armeabi-v7a\il2cppOutput/mscorlib10.cpp:29720)
(EqualityComparer_1_CreateComparer_m7F024F23DDFE5E6E830BB8BBECF5F3068CB8983A_gshared at :?) /data/app/com.DefaultCompany.TestIL2CPPEnumCrash-mm6MQ-RMY4OdGuAPf37FMw==/lib/arm64/libil2cpp.so (BuildId: 69920deb386bce71f8c9a3e29a8bf9cad6442bea)
(EqualityComparer_1_get_Default_m3016CE19FBFD14C31671F2CBE61FC268422DD56A_gshared at D:\Projects\TestIL2CPPEnumCrash\Library\Il2cppBuildCache\Android\armeabi-v7a\il2cppOutput/Generics2.cpp:21539)
(Dictionary_2__ctor_mED26A3694A5751DBB0D7ECBF7515E1778EAC10E9_gshared at D:\Projects\TestIL2CPPEnumCrash\Library\Il2cppBuildCache\Android\armeabi-v7a\il2cppOutput/Generics1.cpp:19430)
(Dictionary_2__ctor_m4CDC369DACB9FC7AE8B8F244E2B0C5FF116F25EA(Dictionary_2_t244EE33C54709A3355AFF7F5404A57130E298D26*, MethodInfo const*) at D:\Projects\TestIL2CPPEnumCrash\Library\Il2cppBuildCache\Android\armeabi-v7a\il2cppOutput/Assembly-CSharp.cpp:3239)
(RunHelper_Run_mBBC2BEC598825FBD83A5B38B0A4D6A5022DE04DC at D:\Projects\TestIL2CPPEnumCrash\Library\Il2cppBuildCache\Android\armeabi-v7a\il2cppOutput/Assembly-CSharp.cpp:3684)
(Test_Run_m45843088227639CEE9235CE075AD1745C1FEFCAA at D:\Projects\TestIL2CPPEnumCrash\Library\Il2cppBuildCache\Android\armeabi-v7a\il2cppOutput/Assembly-CSharp.cpp:3791)
(ThreadStart_Invoke_m784444605A7ADF6A9948A4587DF33CDAC1B06536 at D:\Projects\TestIL2CPPEnumCrash\Library\Il2cppBuildCache\Android\armeabi-v7a\il2cppOutput/mscorlib13.cpp:30338)
(ContextCallback_Invoke_mF4F8496213E8F0925947DD8994A477AE2E54EFDF at :?)
(ExecutionContext_RunInternal_mDC2CC2460328664F8983C6F79354C7085174270A at D:\Projects\TestIL2CPPEnumCrash\Library\Il2cppBuildCache\Android\armeabi-v7a\il2cppOutput/mscorlib5.cpp:22272)
(ThreadStart_Invoke_m784444605A7ADF6A9948A4587DF33CDAC1B06536 at :?)
(RuntimeInvoker_TrueVoid_t700C6383A2A510C2CF4DD86DABD5CA9FF70ADAC5(void ()(), MethodInfo const, void*, void**) at D:\Projects\TestIL2CPPEnumCrash\Library\Il2cppBuildCache\Android\armeabi-v7a\il2cppOutput/Il2CppInvokerTable.cpp:20695)
(il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**) at C:\Program Files\Unity\Hub\Editor\2020.3.42f1\Editor\Data\il2cpp\libil2cpp\vm/Runtime.cpp:556)
(il2cpp::icalls::mscorlib::System::Threading::ThreadStart(void*) at C:\Program Files\Unity\Hub\Editor\2020.3.42f1\Editor\Data\il2cpp\libil2cpp\icalls\mscorlib\System.Threading/Thread.cpp:156)
(il2cpp:s::RunWrapper(void*) at C:\Program Files\Unity\Hub\Editor\2020.3.42f1\Editor\Data\il2cpp\libil2cpp\os/Thread.cpp:183)
(il2cpp:s::ThreadImpl::ThreadStartWrapper(void*) at C:\Program Files\Unity\Hub\Editor\2020.3.42f1\Editor\Data\il2cpp\libil2cpp\os\Posix/ThreadImpl.cpp:125)
(libc.so not found) /system/lib64/libc.so (__pthread_start(void*)+36) (BuildId: 0d96c0a43d600bd26081c8785158f465)
(libc.so not found) /system/lib64/libc.so (__start_thread+68) (BuildId: 0d96c0a43d600bd26081c8785158f465)
UPDATE:
After some investigation, I found it’s due to the following code (Line 24):
Suppose a thread is executing ‘CreateClass’ to Line 25, the other thread can get the pointer to the class instance, but its members have not been assigned.
Thanks for the bug report and the investigation. It does look like some kind of initialization order issue. I’ll ask our QA team to prioritize this issue.