Unity 3d 5.1.4f1 and 5.3 game doesn't run on iOS8 with IL2CPP

Hello,

We are facing an issue with iOS builds when IL2CPP is enabled with a .NET 2.0. The build process works fine - but the game does not launch and crashed with the following error :

il2cpp::icalls::mscorlib::System::String::RedirectToCreateString

There was a previously reported issue similar to this on stackoverflow.

I am also uploading an image of where the issue occurs when the game is launched on the device. I have tried this on 5.1.4f1 and 5.3 - same problem. The build works fine without IL2CPP.

Thanks
Ajit

@isuseragoat

This usually means that something is wrong with the version of the mscorlib.dll used in your project. Likely it is from the wrong version of Mono. Do you do anything special in this project with 3rd-party assemblies that are not built with Unity? Also, can you build and run a simple project that just creates a string a logs it (that should exercise this code)?

Thanks for the response, Josh!

I am using the same mono editor/package that came with the Unity archive. Could you let me know how there could be a issue with the mscorlib.dll version in this case? And is there any way I can resolve this issue with the “correct version” of mscorlib.dll?
All the dll’s used in the project are built with Unity!

@isuseragoat

If you’re not doing anything special with mscorlib.dll then there may be more to this issue than I first anticipated. Can you submit a bug report and include the project that causes this issue? We would love to take a look at it and correct the problem.

The project that we are working on is a large size project - so I am not entirely sure how we can have you guys take a look at this problem. Is there a better way to understand what is actually going on? Without knowing what is really causing the problem, I am not sure what a sample project that could potentially reproduce this issue should even consist of.

Also - I have to mention that I tried a few builds today with IL2CPP , .NET 2.0, and ARMv7 setting - it worked fine 8 out of 10 times. But the 2 builds, crashed and never ran. So it seems to be occurring sporadically as well.

@isuseragoat

Can you get the full native call stack from Xcode when this crash happens? That should at least indicate what part of the project is causing the problem. That might help us narrow things down to a smaller case we can reproduce and fix here.

I’m also a bit surprised that this is intermittent. I don’t understand the problem well enough yet to say much more though.

Here is the screenshot with the call stack. In addition, I have also grabbed a screenshot of the Enviroment_GetCommand… stack! Let me know your thoughts and if you need more detail.


@isuseragoat

Can you select all of the frames in Xcode and copy them out as text? The screen shots don’t have the full names of the functions shown, so it is a bit difficult to tell what the problem is.

Sure.

#1 0x000000010294c7bc in il2cpp::icalls::mscorlib::System::String::RedirectToCreateString() at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/icalls/mscorlib/System/String.cpp:24
#2 0x000000010291a270 in GetSkyboxMaterial [inlined] at /Users/builduser/buildslave/unity/build/./Runtime/Camera/RenderSettings.h:112
#3 0x000000010158e59c in ::Environment_GetCommandLineArgs_m21969(Object_t *, const MethodInfo *) at /Users/ajit/Desktop/buildnew6678_testwithourcameraunits/il2cpp_output/Bulk_mscorlib_1.cpp:63536
#4 0x000000010158e504 in ::Environment_get_CommandLine_m20773(Object_t *, const MethodInfo ) at /Users/ajit/Desktop/buildnew6678_testwithourcameraunits/il2cpp_output/Bulk_mscorlib_1.cpp:63443
#5 0x000000010187356c in ::U23U3Dq7LhBzlAM0p_z4c86lULAVyPv6gxoQqRtzu5SxHU24fT8YU3D__ctor_m25004(U23U3Dq7LhBzlAM0p_z4c86lULAVyPv6gxoQqRtzu5SxHU24fT8YU3D_t5187 , const MethodInfo ) at /Users/ajit/Desktop/buildnew6678_testwithourcameraunits/il2cpp_output/Bulk_uLink_0.cpp:2465
#6 0x00000001018737b8 in ::U23U3Dq7LhBzlAM0p_z4c86lULAVyPv6gxoQqRtzu5SxHU24fT8YU3D__cctor_m25005(Object_t , const MethodInfo ) at /Users/ajit/Desktop/buildnew6678_testwithourcameraunits/il2cpp_output/Bulk_uLink_0.cpp:2504
#7 0x0000000101ea33b8 in RuntimeInvoker_Void_t1039(MethodInfo const
, void
, void
) at /Users/ajit/Desktop/buildnew6678_testwithourcameraunits/il2cpp_output/Il2CppInvokerTable.cpp:990
#8 0x000000010294b090 in il2cpp::vm::Runtime::ClassInit(TypeInfo
) ()
#9 0x000000010188c5cc in ::U23U3DqMtnz1_Kjq47SfTh3G5nQnRJC9K93uSU2457txIOGXXO4QU3D__ctor_m25292(U23U3DqMtnz1_Kjq47SfTh3G5nQnRJC9K93uSU2457txIOGXXO4QU3D_t5204 *, U23U3Dq6caGTOO_zz2NSCtvuEbjkmSfo4SUmdHvqOmzD_10zBU24eQUv7zhmlyL2xCnTWn2Sl_t5185 *, const MethodInfo *) at /Users/ajit/Desktop/buildnew6678_testwithourcameraunits/il2cpp_output/Bulk_uLink_0.cpp:21944
#10 0x00000001018c58a8 in ::U23U3DqTXHnB7reDRXRKkKewSH1JRoAbwF7yFeFsE6KWoIrbwwU3D__ctor_m25789(U23U3DqTXHnB7reDRXRKkKewSH1JRoAbwF7yFeFsE6KWoIrbwwU3D_t5256 *, U23U3Dq6caGTOO_zz2NSCtvuEbjkmSfo4SUmdHvqOmzD_10zBU24eQUv7zhmlyL2xCnTWn2Sl_t5185 *, const MethodInfo ) at /Users/ajit/Desktop/buildnew6678_testwithourcameraunits/il2cpp_output/Bulk_uLink_0.cpp:58596
#11 0x000000010189d050 in ::U23U3DqmX90ERLKb4Jz68RZezchoVFxjBD0JBDT5i8U24yTKMz6IU3D__ctor_m25333(U23U3DqmX90ERLKb4Jz68RZezchoVFxjBD0JBDT5i8U24yTKMz6IU3D_t5221 , const MethodInfo ) at /Users/ajit/Desktop/buildnew6678_testwithourcameraunits/il2cpp_output/Bulk_uLink_0.cpp:25474
#12 0x000000010189cb48 in ::U23U3Dqf8N9KZ0WJpXPw0LFkJEVFZfSPfuIIpcHNOvXT4dUkAQU3D__ctor_m25173(U23U3Dqf8N9KZ0WJpXPw0LFkJEVFZfSPfuIIpcHNOvXT4dUkAQU3D_t5220 , const MethodInfo ) at /Users/ajit/Desktop/buildnew6678_testwithourcameraunits/il2cpp_output/Bulk_uLink_0.cpp:13357
#13 0x00000001018a0cac in ::U23U3Dqi4CVMAFaFSdKxXmzr46dbkAuLshsB8XajRceq6g9X6IU3D__ctor_m25194(U23U3Dqi4CVMAFaFSdKxXmzr46dbkAuLshsB8XajRceq6g9X6IU3D_t5229 , const MethodInfo ) at /Users/ajit/Desktop/buildnew6678_testwithourcameraunits/il2cpp_output/Bulk_uLink_0.cpp:14913
#14 0x000000010192e378 in ::Network__cctor_m26091(Object_t , const MethodInfo ) at /Users/ajit/Desktop/buildnew6678_testwithourcameraunits/il2cpp_output/Bulk_uLink_1.cpp:10571
#15 0x0000000101ea33b8 in RuntimeInvoker_Void_t1039(MethodInfo const
, void
, void
) at /Users/ajit/Desktop/buildnew6678_testwithourcameraunits/il2cpp_output/Il2CppInvokerTable.cpp:990
#16 0x000000010294b090 in il2cpp::vm::Runtime::ClassInit(TypeInfo
) ()
#17 0x0000000100925694 in ::Manager__cctor_m17402(Object_t , const MethodInfo ) at /Users/ajit/Desktop/buildnew6678_testwithourcameraunits/il2cpp_output/Bulk_Hydra_1.cpp:7792
#18 0x0000000101ea33b8 in RuntimeInvoker_Void_t1039(MethodInfo const
, void
, void
) at /Users/ajit/Desktop/buildnew6678_testwithourcameraunits/il2cpp_output/Il2CppInvokerTable.cpp:990
#19 0x000000010294b090 in il2cpp::vm::Runtime::ClassInit(TypeInfo
) ()
#20 0x000000010294425c in il2cpp::vm::Object::NewAllocSpecific(TypeInfo
) ()
#21 0x0000000102914204 in ::il2cpp_object_new(const TypeInfo *) at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/il2cpp-api.cpp:808
#22 0x00000001021e9cac in ::RebuildMonoInstance() at /Users/builduser/buildslave/unity/build/Runtime/Mono/MonoBehaviour.cpp:1580
#23 0x000000010222604c in ::produceObjectInternal() at /Users/builduser/buildslave/unity/build/Runtime/Serialize/PersistentManager.cpp:1278
#24 0x0000000102225d80 in ::CreateThreadActivationQueueEntry() at /Users/builduser/buildslave/unity/build/Runtime/Serialize/PersistentManager.cpp:1170
#25 0x0000000102226390 in ::preallocateObjectThreaded() at /Users/builduser/buildslave/unity/build/Runtime/Serialize/PersistentManager.cpp:1310
#26 0x000000010202a304 in AssignObjectFromInstanceID [inlined] at /Users/builduser/buildslave/unity/build/Runtime/BaseClasses/ImmediatePtr.h:47
#27 0x000000010202a2fc in ::Transfer<StreamedBinaryRead >() at /Users/builduser/buildslave/unity/build/Runtime/BaseClasses/ImmediatePtr.h:102
#28 0x000000010202a14c in ::TransferSTLStyleArray<dynamic_array<std::__1::pair<int, ImmediatePtrUnity::Component >, 8> >() at /Users/builduser/buildslave/unity/build/./Runtime/Serialize/TransferFunctions/StreamedBinaryRead.h:122
#29 0x00000001020288c4 in Transfer<StreamedBinaryRead > [inlined] at /Users/builduser/buildslave/unity/build/./Runtime/Serialize/SerializeTraits.h:506
#30 0x00000001020288b8 in Transfer<dynamic_array<std::__1::pair<int, ImmediatePtrUnity::Component >, 8> > [inlined] at /Users/builduser/buildslave/unity/build/./Runtime/Serialize/TransferFunctions/StreamedBinaryRead.h:150
#31 0x00000001020288b8 in TransferComponents<StreamedBinaryRead > [inlined] at /Users/builduser/buildslave/unity/build/Runtime/BaseClasses/GameObject.cpp:926
#32 0x00000001020288ac in ::Transfer<StreamedBinaryRead >() at /Users/builduser/buildslave/unity/build/Runtime/BaseClasses/GameObject.cpp:935
#33 0x0000000102027eec in AutoScopeRoot [inlined] at /Users/builduser/buildslave/unity/build/./Runtime/Allocator/MemoryMacros.h:109
#34 0x0000000102027ed4 in AutoScopeRoot [inlined] at /Users/builduser/buildslave/unity/build/./Runtime/Allocator/MemoryMacros.h:109
#35 0x0000000102027ed4 in ::VirtualRedirectTransfer() at /Users/builduser/buildslave/unity/build/Runtime/BaseClasses/GameObject.cpp:1356
#36 0x000000010222da90 in ::ReadObject() at /Users/builduser/buildslave/unity/build/Runtime/Serialize/SerializedFile.cpp:1835
#37 0x0000000102226a24 in ::LoadFileCompletelyThreaded() at /Users/builduser/buildslave/unity/build/Runtime/Serialize/PersistentManager.cpp:1601
#38 0x000000010219c07c in ::perform() at /Users/builduser/buildslave/unity/build/Runtime/Misc/LoadSceneOperation.cpp:131
#39 0x000000010219ace4 in ::processSingleOperation() at /Users/builduser/buildslave/unity/build/Runtime/Misc/PreloadManager.cpp:274
#40 0x000000010219aafc in ::Run() at /Users/builduser/buildslave/unity/build/Runtime/Misc/PreloadManager.cpp:323
#41 0x000000010219aab8 in ::Run() at /Users/builduser/buildslave/unity/build/Runtime/Misc/PreloadManager.cpp:180
#42 0x000000010225c7d8 in ::RunThreadWrapper() at /Users/builduser/buildslave/unity/build/Runtime/Threads/Thread.cpp:40
#43 0x00000001846a7b28 in _pthread_body ()
#44 0x00000001846a7a8c in _pthread_start ()

@isuseragoat

Thanks for that call stack. It is a bit difficult to tell what is happening, since it look like the assembly being executed here had been obfuscated. It seems to be named uLink.dll.

But the real problem seems lie in the fact that Environment.GetCommandLineArgs (a managed method in the Mono class libraries) calls the native code in RedirectToCreateString. This is certainly not correct, I don’t see GetCommandLineArgs calling that method on any code path. So I’m really curious to know why that call is made.

Although the project is large, if you can submit a bug report and we can get the project via a different method (other than the bug reporter), I would love to have a look at it. Is it possible for us to work something out like that?

Can we have a separate line of communication during this process (in addition to submitting a bug report and tracking it there) - We don’t have a problem sharing the project with you guys (we can discuss how this can be provided to your team) so that there can be a resolution to this issue. Will you/Unity be able to sign NDA’s for this?

@isuseragoat

I’ll contact you privately about this.

@isuseragoat

Hmm, something in our forum software is preventing me from starting a private conversation with you. Can you ping me via email? joshuap@unity3d.com.

Sure. I’ll shoot you an email right now

email sent!