tuyoogame / huatuo

huatuo是一个特性完整、零成本、高性能、低内存的近乎完美的Unity全平台原生c#热更方案。 Huatuo is a fully featured, zero-cost, high-performance, low-memory solution for Unity's all-platform native c# hotfix
MIT License
2.31k stars 377 forks source link

3个直接崩溃的例子 #23

Closed tinygridlock closed 2 years ago

tinygridlock commented 2 years ago

2020.3.7f1 standalone包

using System; using System.Collections.Generic; using UnityEngine;

public class App { public static int Main() { Test3(); Test4(); Test5(); return 0; }

public static void Test3()
{
    var a1 = new A1();
    a1.Test<string>((a) => { });
    a1.Test<string>((a) => { });
}

public class A1
{
    public void Test<T>(Action<T> callback)
    {
        callback?.Invoke(default);
    }
}

public static void Test4()
{
    var b = new B2();
    b.Dict = new Dictionary<string, string>();
    b.Dict.Add("123", "123");
    b.Dict["123"] = "456";
}

public class B2
{
    public Dictionary<string, string> Dict { get; set; }
}

public static void Test5()
{
    C3 a;
    a.F = 123;
    a.V = new Vector3(4, 5, 6);
    var pos = a.V;
    pos.x += 111;
}

public struct C3
{
    public float F;
    public Vector3 V;
}

}

pirunxi commented 2 years ago

复测,只有Test5才会崩溃。 已修复提交。

tinygridlock commented 2 years ago

麻烦再确认下看?Test3和Test4在4月8日之前的版本是好的,我这边在目前最新的版本里崩溃了

pirunxi commented 2 years ago

我就是拿最新的huatuo版本测的。这样吧,你把你的libil2cpp目录QQ上发给我。

tinygridlock commented 2 years ago

我这边再确认下,如果还有问题,在QQ上把目录发你。

tinygridlock commented 2 years ago

我这边测试发现是编译成release的dll会崩,debug的dll不崩

pirunxi commented 2 years ago

ok. 我复测一下。由于release与debug生成的指令不一样,所以确实可能发生这种情况。 很重要。帮助我们发现几个bug。

pirunxi commented 2 years ago

确认bug。已修复。dup指令未正确计算栈大小引起。