Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

64-bit iOS il2cpp crashes

Discussion in 'iOS and tvOS' started by Harito, Apr 30, 2015.

  1. Harito

    Harito

    Joined:
    Mar 3, 2014
    Posts:
    22
    Hello,

    I've been unfortunately plagued by crashes with on arm64 devices on build that work without a hitch on 32-bit iOS devices, using the il2cpp backend.

    The latest one, which seems to occur randomly when instantiating some GameObbjects dumps the following callstack :


    The previous, which I managed to work around by removing calls to UnloadUnusedAssets and GC.Collect, had the following call stack :


    Please help me out here. I'm in a very frustrating situation when I have my application finally complete, but no way of mitigating the crashes that are occurring on 64-bit devices.

    I am using Unity 4.6.4p4, the crashes, or at least the one with UnloadUnusedAssets occurred also in Unity 4.6.4p3. The project is being built using Xcode 6.3.1. The crashes occur in both Developer and Release builds, that is, in both -O0 and -Os optimization levels. So no compiler funny business seems to be going on.

    Please note that there is some imperative time sensitivity with this project, so your help will be held in great regard. Thank you.
     
  2. Mantas-Puida

    Mantas-Puida

    Unity Technologies

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    We would need some repro case to debug the issue. Could you please submit your project with bugreport?
     
  3. Harito

    Harito

    Joined:
    Mar 3, 2014
    Posts:
    22
    I'll see if I can create a repro case somehow, because I certainly can't submit my whole project. Otherwise I guess I'm down to more workarounds.
     
  4. joncham

    joncham

    Unity Technologies

    Joined:
    Dec 1, 2011
    Posts:
    276
    Hello,

    We had a 64-bit only bug related to arrays (that could corrupt memory), but that should have been fixed in 4.6.4p4. Please verify the install for 4.6.4p4 overwrote your previous install. If that release (or 4.6.5) does not fix your issue please file a bug.

    Thanks,
    Jonathan
     
  5. Harito

    Harito

    Joined:
    Mar 3, 2014
    Posts:
    22
    Hi Jonathan,

    Thanks for responding! Now that you mention that, I may have not pointed my build system to use the latest version of Unity for batch mode. Since I did a side by side install and have both p3 and p4 installed. I'm hoping this is the case and that everything is resolved! I will double check and do a new clean build and report back.

    Thanks,
    Harold
     
  6. Harito

    Harito

    Joined:
    Mar 3, 2014
    Posts:
    22
    No go.

    I uninstalled both p3 and p4, did a clean install of 4.6.5, then ran a new clean build and I still got the same crash :

     
  7. Harito

    Harito

    Joined:
    Mar 3, 2014
    Posts:
    22
    Hello once again, just to update on what was causing it. My apologies, the second crash was something I overlooked.

    I'll mention it here in case someone comes across a similar issue :

    I had forgotten I had a union struct type ( StructLayout( LayoutKind.Explicit ) + FieldOffsets ). Since when I started developing this title I had no regard for a 64-bit executable and the offsets were set to 4-byte boundaries. I discovered the object that was being instanced when the crash occurred had serialized data that contained this union, then I realized what was causing the memory corruption. So, remember to set your offsets to 8-byte boundaries for reference types.


    Thanks for the attention and sorry for wasting anybody's time.

    Regarding, the former crash ( the one with UnloadUnusedAssets ): I haven't checked if it still occurs in the current version. I commented out the code that called it for the time being, but I will test again later to see if the crash occurs in the latest version.

    Thanks again!
     
  8. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,778
    Thanks for following up on this, and please let us know what else you determine.
     
  9. kaushik-d

    kaushik-d

    Joined:
    Aug 25, 2011
    Posts:
    19
    I am getting a similar crash on iOS devices with IL2CPP and Universal architecture. The build is working fine when it is built with Mono. I don't have anything like a union and as mentioned in this thread any threads. This is probably happening with some of my scripts. It only happens when I load the main level. Does not happen when I load an empty scene. Need to upload this to App Store soon. Does anyone have any pointers to what kind of script could be causing this problem?
    This is what the error looks like in XCode:

    UnityPreload (23)#0 0x014c1f3e in il2cpp::vm::GenericClass::IsValueType(Il2CppGenericClass*) at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/GenericClass.cpp:239
    #1 0x014d6d5e in il2cpp::icalls::mscorlib::System::Type::get_IsGenericType(Il2CppReflectionType*) at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/icalls/mscorlib/System/Type.cpp:58
    #2 0x014befb6 in il2cpp::vm::LayoutFieldsLocked(TypeInfo*, il2cpp::eek:s::FastAutoLock const&) [inlined] at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/Class.cpp:841
    #3 0x014bef32 in il2cpp::vm::SetupFieldsLocked(TypeInfo*, il2cpp::eek:s::FastAutoLock const&) at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/Class.cpp:988
    #4 0x014bf7a6 in il2cpp::vm::InitLocked(TypeInfo*, il2cpp::eek:s::FastAutoLock const&) at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/Class.cpp:1357
    #5 0x014be426 in il2cpp::vm::Class::Init(TypeInfo*) at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/Class.cpp:1405
    #6 0x014c9146 in il2cpp::icalls::mscorlib::System::Object::MemberwiseClone(Il2CppObject*) at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/icalls/mscorlib/System/Object.cpp:31
    #7 0x0149bf7a in ::il2cpp_object_new(const TypeInfo *) at /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/il2cpp-api.cpp:808
    #8 0x00d0ac5e in ::RebuildMonoInstance() at /Users/builduser/buildslave/unity/build/Runtime/Mono/MonoBehaviour.cpp:1514
    #9 0x00d3c7d4 in ::produceObjectInternal() at /Users/builduser/buildslave/unity/build/Runtime/Serialize/PersistentManager.cpp:1278
    #10 0x00d3c52e in ::CreateThreadActivationQueueEntry() at /Users/builduser/buildslave/unity/build/Runtime/Serialize/PersistentManager.cpp:1170
    #11 0x00d3cb54 in ::preallocateObjectThreaded() at /Users/builduser/buildslave/unity/build/Runtime/Serialize/PersistentManager.cpp:1310
    #12 0x00b6bbbe in AssignObjectFromInstanceID [inlined] at /Users/builduser/buildslave/unity/build/./Runtime/BaseClasses/ImmediatePtr.h:47
    #13 0x00b6bbba in ::Transfer<StreamedBinaryRead<false> >() at /Users/builduser/buildslave/unity/build/./Runtime/BaseClasses/ImmediatePtr.h:102
    #14 0x00b6ba82 in ::TransferSTLStyleArray<dynamic_array<std::__1::pair<int, ImmediatePtr<Unity::Component> >, 4> >() at /Users/builduser/buildslave/unity/build/./Runtime/Serialize/TransferFunctions/StreamedBinaryRead.h:124
    #15 0x00b69f88 in Transfer<StreamedBinaryRead<false> > [inlined] at /Users/builduser/buildslave/unity/build/./Runtime/Serialize/SerializeTraits.h:506
    #16 0x00b69f7e in Transfer<dynamic_array<std::__1::pair<int, ImmediatePtr<Unity::Component> >, 4> > [inlined] at /Users/builduser/buildslave/unity/build/./Runtime/Serialize/TransferFunctions/StreamedBinaryRead.h:160
    #17 0x00b69f7e in TransferComponents<StreamedBinaryRead<false> > [inlined] at /Users/builduser/buildslave/unity/build/Runtime/BaseClasses/GameObject.cpp:829
    #18 0x00b69f44 in ::Transfer<StreamedBinaryRead<false> >() at /Users/builduser/buildslave/unity/build/Runtime/BaseClasses/GameObject.cpp:838
    #19 0x00b694a4 in Transfer<StreamedBinaryRead<false> > [inlined] at /Users/builduser/buildslave/unity/build/./Runtime/Serialize/SerializeTraitsBase.h:60
    #20 0x00b69478 in Transfer<Unity::GameObject> [inlined] at /Users/builduser/buildslave/unity/build/./Runtime/Serialize/TransferFunctions/StreamedBinaryRead.h:160
    #21 0x00b69478 in TransferBase<Unity::GameObject> [inlined] at /Users/builduser/buildslave/unity/build/./Runtime/Serialize/TransferFunctions/StreamedBinaryRead.h:153
    #22 0x00b69478 in ::VirtualRedirectTransfer() at /Users/builduser/buildslave/unity/build/Runtime/BaseClasses/GameObject.cpp:1262
    #23 0x00d447fc in ::ReadObject() at /Users/builduser/buildslave/unity/build/Runtime/Serialize/SerializedFile.cpp:1869
    #24 0x00d3d386 in ::LoadFileCompletelyThreaded() at /Users/builduser/buildslave/unity/build/Runtime/Serialize/PersistentManager.cpp:1601
    #25 0x00cc2380 in ::perform() at /Users/builduser/buildslave/unity/build/Runtime/Misc/LoadSceneOperation.cpp:160
    #26 0x00cc0d82 in ::processSingleOperation() at /Users/builduser/buildslave/unity/build/Runtime/Misc/PreloadManager.cpp:273
    #27 0x00cc0b10 in ::Run() at /Users/builduser/buildslave/unity/build/Runtime/Misc/PreloadManager.cpp:331
    #28 0x00cc0adc in ::Run() at /Users/builduser/buildslave/unity/build/Runtime/Misc/PreloadManager.cpp:180
    #29 0x00d6daca in ::RunThreadWrapper() at /Users/builduser/buildslave/unity/build/Runtime/Threads/Thread.cpp:40
    #30 0x227fd85a in _pthread_body ()


    This is happening on Unity5.2.3f1. Installing 5.3.1p1 to see if this goes away.
     
  10. kaushik-d

    kaushik-d

    Joined:
    Aug 25, 2011
    Posts:
    19
    Ok, this seems to be a problem when I have nested generic Dictionary. I've attached a bare-minimal stripped down version of my project to reproduce the issue.

    Same problem with 5.3.1p1. Is there any work-around for this, other than changing code (where I use something else, instead of nested generic classes)?
     

    Attached Files:

    Last edited: Jan 6, 2016
  11. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,778
    @kaushik.d

    This nested generic type should work fine. Can you submit a bug report with a project that causes this issue? I would like to investigate why this is happening.
     
  12. kaushik-d

    kaushik-d

    Joined:
    Aug 25, 2011
    Posts:
    19
    I have filed a bug report with the issue. Did some more testing and figured that simple cases with primitive type works. When there are enums as key/values in a dictionary the crashes occur. I've edited my earlier post regarding this.
     
  13. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,778
    @kaushik.d

    Thanks. Can you let me know the bug report number?
     
  14. kaushik-d

    kaushik-d

    Joined:
    Aug 25, 2011
    Posts:
    19
  15. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,778