Search Unity

  1. Unity 2019.2 is now released.
    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:
    2,395
    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:
    2,395
    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:
    6,518
    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:
    2,395
    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.