Hello, after the new release we encounter this crash that affects 20%+ of Android and iOS sessions; please see the platforms stack trace. Seems like it’s Unity related… Any thoughts on how to fix this?
Unity 2021.3.12f1, also tested on 2021.3.16f1, both has the same issue
I’ve made a more detailed research of native stack trace crash (see attached) at _CombatMaster.Battle15.cpp:6970 and I found a matched C# code — please see screenshot attached.
It seems like a Unity exception when we try to make “exception to string”…
Could you please look into it and share your thoughts. Thank you!
It looks like the stack trace generation code runs into a problem processing some async method, or maybe an attribute on an async method somewhere in the call stack. It is likely related to the AsyncUniTaskMethodBuilder type which is used here.
This is not something we have seen before - can you submit a bug report for this?
I can’t create a bug report because I can’t reproduce it locally. But as a workaround, I turned off all the logs in the game and the collection of stack traces and… the crash disappeared!
Looking into the implementation of get_base_method in IL2CPP and Mono, I found in Mono it checks if slot is valid before accessing vtable:
if (klass == method->klass)
return method;
/*This is possible if definition == FALSE.
* Do it here to be really sure we don't read invalid memory.
*/
if (slot >= m_class_get_vtable_size (klass))
return method;
mono_class_setup_vtable (klass);
result = m_class_get_vtable (klass) [slot];
But in IL2CPP, it uses slot to access vtable directly:
if (klass == method2->klass)
return method;
il2cpp::vm::Class::Init(klass);
result = klass->vtable[method2->slot].method;
Based on it, I tried to create a situation to test:
Create a dll, which contains a class ‘A’ which contains a virtual method ‘Foo’
Create another dll, which contains a class ‘B’ which inherits class ‘A’ and overrides method ‘Foo’
Remove “virtual” from method ‘Foo’ in ‘A’ and recompile the first dll
Copy the precompiled dlls created in step 2 and 3 into a Unity project
Call GetCustomAttributes for method ‘foo’ in ‘B’ in Unity
It can reproduce a similar crash in 2021.3.28 definitely:
The project has been submitted: IN-48686.
Not sure if this is the same issue with the posts above.
Thanks, this does help. It sounds like this is a bug in IL2CPP, which we will correct. I appreciate the time and effort you put into tracking down the use case here!
Maybe there is some subtle difference in this case. The fix for the originally reported issue is in 2021.3.11f1. Is this something you can reproduce, or are you only seeing it in crash reports?