gpt4 book ai didi

c# - .NET 4 中的 StackOverflowException

转载 作者:可可西里 更新时间:2023-11-01 07:47:28 26 4
gpt4 key购买 nike

在我升级到 .NET 4 (x64) 之前,以下代码工作正常

namespace CrashME
{
class Program
{
private static volatile bool testCrash = false;
private static void Crash()
{
try
{
}
finally
{
HttpRuntime.Cache.Insert("xxx", testCrash);
}

}

static void Main(string[] args)
{
Crash();
// Works on .NET 3.5 , crash on .NET 4
}
}
}

我是刚刚发现了一个运行时错误,还是我的使用存在问题?

最佳答案

这似乎是 CLR 中的错​​误 - 您应该向 Microsoft 报告它。

请注意 StackOverflowException 在 CLR 尝试执行 Crash 时发生,而不是 执行期间发生Crash 方法 - 实际上程序永远不会进入该方法。这似乎表明这是 CLR 中的一些低级故障。 (另请注意,抛出的异常也没有堆栈跟踪)。

此异常非常特定于这种情况 - 更改许多事情中的任何一个都可以解决此问题,例如以下代码可以正常工作:

private static void Crash()
{
bool testCrash2 = testCrash;
try { }
finally
{
HttpRuntime.Cache.Insert("xxx", testCrash2);
}
}

我建议您向 Microsoft 报告此问题,但同时尝试通过调整您的代码来解决此问题。

关于c# - .NET 4 中的 StackOverflowException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3562008/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com