Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

2019.1 IL2CPP runtime crash on vm::Exception::PrepareExceptionForThrow

Discussion in 'Windows' started by snacktime, Apr 19, 2019.

  1. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    So there are two exceptions in the code that is in the call stack here that looks to be the trigger. Two lines after the PrepareExceptionForThrow line the callstack ends in il2cpp_find_catch_sequence_point_in_method.

    Does this code look problematic in any way? The exceptions are wrapped in an if null and an if length check.

    Code (csharp):
    1.  
    2. throw new IndexOutOfRangeException(
    3.                     nameof(array) + " is shorter than " + nameof(nativeArray));
    4.  
    5. throw new NullReferenceException(nameof(array) + " is null");
    6.  
     
  2. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Oh hold on I missed the correct line in user code. It looks like it's failing where the code is emitting IL at runtime. That would definitely be an issue right?

    Specifically it's getting an instance of DynamicMethod and then calling GetILGenerator on that and then Emit.
     
  3. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    What's the native callstack for the crash?

    DynamicMethod is definitely not supported in IL2CPP - it's part of System.Reflection.Emit and requires a JIT to work properly. IL2CPP is an AOT runtime, and does not implement System.Reflection.Emit.
     
  4. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    It was definitely the IL, didn't look at the native callstack. I was just surprised to see the author in question do something that wouldn't be compatible, so it made me wonder if there was something I was missing.
     
  5. JakeSimpson

    JakeSimpson

    Joined:
    Dec 4, 2019
    Posts:
    20
    I get this happening constantly now, with out project. We cannot debug on IOS anymore, because if we mark the project as Script Debug, then this error happens whenever a null reference is found.

    This is a major problem since I can't debug in Windows (or in OSX mode), since this is happening inside of code that is using Prime31's plugin, for using the GameCenter networking (so the code isn't present on Windows builds), ergo, we can't debug it using the standard tools.

    This is blocking us big time - any thoughts on what is happening here, and how we can fix it?

    Stack Trace looks like :-

    #0 0x0000000101ee3430 in il2cpp_find_catch_sequence_point_in_method at /Users/builduser/buildslave/unity/build/External/il2cpp/il2cpp/external/mono/mono/mini/debugger-agent.c:6831
    #1 0x0000000101ee0be8 in il2cpp_find_catch_sequence_point_from_exeption [inlined] at /Users/builduser/buildslave/unity/build/External/il2cpp/il2cpp/external/mono/mono/mini/debugger-agent.c:6876
    #2 0x0000000101ee0bac in unity_debugger_agent_handle_exception at /Users/builduser/buildslave/unity/build/External/il2cpp/il2cpp/external/mono/mono/mini/debugger-agent.c:6916
    #3 0x0000000101ea710c in il2cpp::vm::Exception::prepareExceptionForThrow(Il2CppException*, Il2CppSequencePoint*, MethodInfo*) at /Users/builduser/buildslave/unity/build/External/il2cpp/il2cpp/libil2cpp/vm/Exception.cpp:30
    #4 0x0000000101ea71f4 in il2cpp::vm::Exception::Raise(Il2CppException*, Il2CppSequencePoint*, MethodInfo*) at /Users/builduser/buildslave/unity/build/External/il2cpp/il2cpp/libil2cpp/vm/Exception.cpp:65
    #5 0x0000000101ea72c4 in il2cpp::vm::Exception::RaiseNullReferenceException(il2cpp::utils::StringView<char16_t> const&, Il2CppSequencePoint*) at /Users/builduser/buildslave/unity/build/External/il2cpp/il2cpp/libil2cpp/vm/Exception.cpp:86
    #6 0x0000000101ea72a4 in il2cpp::vm::Exception::RaiseNullReferenceException(Il2CppSequencePoint*) at /Users/builduser/buildslave/unity/build/External/il2cpp/il2cpp/libil2cpp/vm/Exception.cpp:81
    #7 0x0000000101e713f0 in il2cpp_codegen_raise_null_reference_exception(Il2CppSequencePoint*) at /Users/builduser/buildslave/unity/build/External/il2cpp/il2cpp/libil2cpp/codegen/il2cpp-codegen-il2cpp.cpp:249
    #8 0x0000000100a6a760 in NullCheck(void*, Il2CppSequencePoint*) at /Users/tnbstudiosprime/Documents/Projects/Giants_Build/IOSBuild/Libraries/libil2cpp/include/codegen/il2cpp-codegen-il2cpp.h:226
    #9 0x00000001020a48e0 in ::populateFriendsScrollView_ForcePopulate_m91F00C75F402B48686B70F547CF36A026F8191F1(PopulateFriendsScrollView_t622BC06B175DE4A8D8ACAF6C5CE0852557088E56 *, const RuntimeMethod *) at /Users/tnbstudiosprime/Documents/Projects/Giants_Build/IOSBuild/Classes/Native/Assembly-CSharp1.cpp:27923
    #10 0x00000001020a9478 in ::populateFriendsScrollView_AllFriendsButton_m900270C312C583465F1E36379120D897EEE93CC3(PopulateFriendsScrollView_t622BC06B175DE4A8D8ACAF6C5CE0852557088E56 *, const RuntimeMethod *) at /Users/tnbstudiosprime/Documents/Projects/Giants_Build/IOSBuild/Classes/Native/Assembly-CSharp1.cpp:28823
    #11 0x00000001020bc588 in ::SetupGameScreen_Start_mDB1F3367FE26191E50DD1EFBD37C6EF3967B757F(SetupGameScreen_t1D5D9532BC82191B9E708A5D0925BB4A28479F17 *, const RuntimeMethod *) at /Users/tnbstudiosprime/Documents/Projects/Giants_Build/IOSBuild/Classes/Native/Assembly-CSharp1.cpp:32118
    #12 0x0000000100c9ad0c in RuntimeInvoker_TrueVoid_t22962CB4C05B1D89B55A6E1139F0E87A90987017(void (*)(), MethodInfo const*, void*, void**) at /Users/tnbstudiosprime/Documents/Projects/Giants_Build/IOSBuild/Classes/Native/Il2CppInvokerTable.cpp:35036
    #13 0x0000000101eb805c in il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**) at /Users/builduser/buildslave/unity/build/External/il2cpp/il2cpp/libil2cpp/vm/Runtime.cpp:542
    #14 0x0000000101744aa4 in ::scripting_method_invoke() at /Users/builduser/buildslave/unity/build/Runtime/ScriptingBackend/Il2Cpp/ScriptingApi_Il2Cpp.cpp:250
    #15 0x00000001017513cc in ::Invoke() at /Users/builduser/buildslave/unity/build/Runtime/Scripting/ScriptingInvocation.cpp:273
    #16 0x0000000101759014 in ::InvokeMethodOrCoroutineChecked() ()
    #17 0x0000000101759160 in ::InvokeMethodOrCoroutineChecked() at /Users/builduser/buildslave/unity/build/Runtime/Mono/MonoBehaviour.cpp:822
    #18 0x000000010175823c in Start [inlined] at /Users/builduser/buildslave/unity/build/Runtime/Mono/MonoBehaviour.cpp:453
    #19 0x00000001017581fc in ::DelayedStartCall() at /Users/builduser/buildslave/unity/build/Runtime/Mono/MonoBehaviour.cpp:1196
    #20 0x0000000101362c30 in ::Update() at /Users/builduser/buildslave/unity/build/Runtime/GameCode/CallDelayed.cpp:180
    #21 0x0000000101529638 in ::Forward() at /Users/builduser/buildslave/unity/build/Runtime/Misc/Player.cpp:1435
    #22 0x00000001015214fc in ::ExecutePlayerLoop() at /Users/builduser/buildslave/unity/build/Runtime/Misc/PlayerLoop.cpp:277
    #23 0x0000000101521558 in ::ExecutePlayerLoop() at /Users/builduser/buildslave/unity/build/Runtime/Misc/PlayerLoop.cpp:294
    #24 0x0000000101521798 in ::playerLoop() at /Users/builduser/buildslave/unity/build/Runtime/Misc/PlayerLoop.cpp:350
    #25 0x0000000101acb5e4 in ::UnityPlayerLoopImpl() ()
    #26 0x0000000100a4c0dc in ::UnityRepaint() at /Users/tnbstudiosprime/Documents/Projects/Giants_Build/IOSBuild/Classes/UnityAppController+Rendering.mm:277
    #27 0x0000000100a4c090 in ::-[UnityAppController(Rendering) repaint]() at /Users/tnbstudiosprime/Documents/Projects/Giants_Build/IOSBuild/Classes/UnityAppController+Rendering.mm:90
    #28 0x0000000100a4bfb0 in ::-[UnityAppController(Rendering) repaintDisplayLink]() at /Users/tnbstudiosprime/Documents/Projects/Giants_Build/IOSBuild/Classes/UnityAppController+Rendering.mm:71
    #29 0x000000010a7555f8 in -[DYDisplayLinkInterposer forwardDisplayLinkCallback:] ()
    #30 0x00000001b8f4988c in CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) ()
    #31 0x00000001b3565934 in IODispatchCalloutFromCFMessage ()
    #32 0x00000001b25718ac in __CFMachPortPerform ()
    #33 0x00000001b259b07c in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
    #34 0x00000001b259a7a8 in __CFRunLoopDoSource1 ()
    #35 0x00000001b259567c in __CFRunLoopRun ()
    #36 0x00000001b2594adc in CFRunLoopRunSpecific ()
    #37 0x00000001bc51a328 in GSEventRunModal ()
    #38 0x00000001b668fae0 in UIApplicationMain ()
    #39 0x0000000100a39f20 in main at /Users/tnbstudiosprime/Documents/Projects/Giants_Build/IOSBuild/Classes/main.mm:40
     
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    Which version of Unity are you using? This looks very similar to an issue that we discovered internally and corrected in 2019.3.
     
  7. JakeSimpson

    JakeSimpson

    Joined:
    Dec 4, 2019
    Posts:
    20
    2019.1.10f - I have no choice in this :( If it's fixed though, then not to worry.