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.61k stars 672 forks source link

下面这段代码在AOT下可以运行,在Ineterpreter 下报错 #142

Closed goon7203233 closed 3 months ago

goon7203233 commented 3 months ago

Describe the bug | 描述问题

Android环境下 下面这段代码在AOT下可以运行,在Ineterpreter 下报错 editor下没有问题

Enviroment | 环境

To Reproduce | 复制步骤

Android环境下 下面这段代码在AOT下可以运行,在Ineterpreter 下报错 editor下没有问题

m = 3 n = 8

public static int Ackermann(int m, int n)
{
    if (m == 0)
    {
        return n + 1;
    }
    else if (m > 0 && n == 0)
    {
        return Ackermann(m - 1, 1);
    }
    else if (m > 0 && n > 0)
    {
        return Ackermann(m - 1, Ackermann(m, n - 1));
    }
    else
    {
        return 0;
    }
}

08-01 23:47:35.720 4036 4055 E Unity : StackOverflowException: AllocFrame 08-01 23:47:35.720 4036 4055 E Unity : at System.Reflection.RuntimeMethodInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Exception& exc) [0x00000] in <000000000000000000000000 00000000>:0 08-01 23:47:35.720 4036 4055 E Unity : at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] param eters, System.Globalization.CultureInfo culture) [0x00000] in <00000000000000000000000000000000>:0 08-01 23:47:35.720 4036 4055 E Unity : at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <00000000000000000000000000000000>:0 08-01 23:47:35.720 4036 4055 E Unity : at BenchmarkTest.BenchmarkTestCases_Inter () [0x00000] in <00000000000000000000000000000000>:0 08-01 23:47:35.720 4036 4055 E Unity : at BenchmarkTest.Update () [0x00000] in <00000000000000000000000000000000>:0 08-01 23:47:35.720 4036 4055 E Unity : at Test_Ineterpreter.Ackermann (System.Int32 m, System.Int32 n) [0x00000] in <00000000000000000000000000000000>:0 08-01 23:47:35.720 4036 4055 E Unity : at Test_Ineterpreter.Ackermann (System.Int32 m, System.Int32 n) [0x00000] in <000000000000000000000000000000

pirunxi commented 3 months ago

这个错误日志是嵌套过深函数栈帧溢出了,mono下不溢出那是因为它的默认帧栈较大。 解决办法为你在 Assemly.Load加载任何热更新代码前 运行 Runtime.SetInterpreterThreadFrameStackSized大小,默认值是2k,你改成4k之类。

如果还有问题去新手群问,或者联系付费技术支持。