focus-creative-games / hybridclr

HybridCLR是一个特性完整、零成本、高性能、低内存的Unity全平台原生c#热更新解决方案。 HybridCLR is a fully featured, zero-cost, high-performance, low-memory solution for Unity's all-platform native c# hotupdate.
https://code-philosophy.com/
MIT License
6.62k stars 673 forks source link

DHE:使用泛型导致崩溃 #50

Closed AlanLiu90 closed 1 year ago

AlanLiu90 commented 1 year ago

环境

Unity 2020.3.33
il2cpp_plus 2020-DHE
hybridclr DHE
hybridclr_unity DHE
OS+Build Windows 10 64 bit
project dhe_demo(没开间接函数优化)

问题

下面代码可复现:

public abstract class A<T>
{
    public List<T> D = new List<T>();
}

public class B<T1, T2> : A<Action<T1, T2>>
{

}

public class C
{

}

public class HotUpdateMain : MonoBehaviour
{
    public B<C, C> B = new B<C, C>();

    void Start()
    {
        UnityEngine.Debug.Log(B.D.Count);
    }
}

崩溃信息:

Exception thrown: read access violation.method->klass->rgctx_data was nullptr.

崩溃调用栈:

GameAssembly.dll!A_1__ctor_mEED8058ABFA500A40294771CB8E97D19EE7AB818_gshared(A_1_t07D96EE2B9CE8B3CD0D4BD89B30F9AC917BB780B * __this, const MethodInfo * method) Line 10606  C++
GameAssembly.dll!B_2__ctor_m60BC8C51983FF411DB5E772CEBC95CD7AB257757_gshared(B_2_t2654A0DA705819C42DC5558AE9A2DD5159BB992D * __this, const MethodInfo * method) Line 36301  C++
GameAssembly.dll!B_2__ctor_mF25B031406C1FDBCB812BCD1EDC944C8771F76BB(B_2_t0B5CD9A23C3DA938F788BE1B5E0E6CACD5A75F16 * __this, const MethodInfo * method) Line 854    C++
GameAssembly.dll!HotUpdateMain__ctor_m5549897CFBEE17CCA2EBEFF1DE62E41891423004(HotUpdateMain_t9691E9193AC822C20C46ED6B1C1F26EEB0EC8F21 * __this, const MethodInfo * method) Line 1223   C++
GameAssembly.dll!RuntimeInvoker_TrueVoid_t700C6383A2A510C2CF4DD86DABD5CA9FF70ADAC5(void(*)() methodPointer, const MethodInfo * methodMetadata, void * obj, void * * args) Line 28206    C++
GameAssembly.dll!il2cpp::vm::Runtime::Invoke(const MethodInfo * method, void * obj, void * * params, Il2CppException * * exc) Line 559  C++
GameAssembly.dll!il2cpp::vm::Runtime::ObjectInitException(Il2CppObject * object, Il2CppException * * exc) Line 600  C++
GameAssembly.dll!il2cpp_runtime_object_init_exception(Il2CppObject * obj, Il2CppException * * exc) Line 1133    C++
UnityPlayer.dll!scripting_unity_engine_object_new_and_invoke_default_constructor(class ScriptingClassPtr,class Object *,class ScriptingExceptionPtr *)  Unknown
UnityPlayer.dll!SerializableManagedRef::RebuildMonoInstance(class Object *,class ScriptingClassPtr,class ScriptingObjectPtr,class MonoScript *) Unknown
AlanLiu90 commented 1 year ago

和其他问题一起添加到#49

pirunxi commented 1 year ago

好的。我们已经安排解决了。