How to reproduce:
1. Open the attached “TestIL2CPPEnumCrash.zip“ project
2. Build for a Standalone Player
3. Run a Build Player
Expected result: The Player opens and closes
Actual result: The Player opens and crashes
Reproducible with: 2020.3.44f1, 2021.3.17f1, 2022.2.5f1, 2023.1.0b2
Reproducible with: Windows, MacOS, Android
Notes:
- The Player crashes after the 1st-2nd attempt
- The crash is not reproducible after the 1st-10th crash (The Player starts acting as expected or freezes)
Forum thread: https://forum.unity.com/threads/il2cpp-crash-calling-array-indexof-on-array-of-enums-running-on-the-thread-pool.1341764/#post-8735814
First few lines of the stack trace:
(GameAssembly) [[EditorLocation]\Data\il2cpp\libil2cpp\vm\Class.cpp:1140] il2cpp::vm::Class::SetupMethods
(GameAssembly) [[EditorLocation]\2020.3.44f1\Editor\Data\il2cpp\libil2cpp\vm\Class.cpp:367] il2cpp::vm::Class::GetMethods
(GameAssembly) [[EditorLocation]\2020.3.44f1\Editor\Data\il2cpp\libil2cpp\icalls\mscorlib\System\MonoType.cpp:322] il2cpp::icalls::mscorlib::System::MonoType::GetConstructors_internal
(GameAssembly) [[EditorLocation]\Data\il2cpp\libil2cpp\icalls\mscorlib\System\RuntimeType.cpp:186] il2cpp::icalls::mscorlib::System::RuntimeType::GetConstructors_native
(GameAssembly) [ProjectLocation\Library\Il2cppBuildCache\Windows\x64\il2cppOutput\mscorlib11.cpp:32075] RuntimeType_GetConstructors_internal_m76E62D68C52B212895C44CE5E213BBA00F5E397F
(GameAssembly) [ProjectLocation\Library\Il2cppBuildCache\Windows\x64\il2cppOutput\mscorlib11.cpp:24620] RuntimeType_GetConstructorCandidates_m1AF80B6730AF93BA20B47C13DDBBF4EC3E79793F