[英]Fatal Execution Engine Error in Managed C# code
I have experienced Access Violation Exceptions and Fatal Execution Engine Error (it seems to be the same error) in managed code in C#. 我在C#中的托管代码中遇到过访问冲突异常和致命执行引擎错误(似乎是同一个错误)。 I have narrowed it down to the following snippet. 我已将其缩小到以下代码段。 Am I missing something? 我错过了什么吗? I thought it should not be possible to these kind of exceptions in managed code. 我认为托管代码中的这些异常应该是不可能的。 I have seen it both in .net 4.7 and 4.5 and on multiple different computers? 我在.net 4.7和4.5以及多台不同的计算机上都看到了它? Is this a known issue in .Net? 这是.Net中的已知问题吗?
public static class FatalExecutionEngineBugExposer
{
public static void Main(string[] args)
{
for (int i = 0; i < 500000; i++)
{
try
{
var testProblem = new TestProblem();
testProblem.AddTrianglesExperiment();
}
catch (Exception e)
{
Console.WriteLine(e.GetBaseException());
}
}
}
public class TestProblem
{
public struct Point
{
public double X, Y, Z;
}
public void AddTrianglesExperiment()
{
var points = new Point[28800];
Parallel.ForEach(Partitioner.Create(0, points.Length),
range =>
{
// Create cache
var cache = new CubeRefCache();
cache.Entries = new CubeRefCacheEntry[20000];
// Add triangles
for (int i = range.Item1; i < range.Item2; i++)
{
ProcessTriangle(ref points[i].X, ref points[i].Y, ref points[i].Z, cache);
}
});
}
void ProcessTriangle(ref double pt1, ref double pt2, ref double pt3, CubeRefCache cache)
{
cache.Add(0, 0);
}
public struct CubeRefCacheEntry
{
public int Index;
public int Item;
}
class CubeRefCache
{
internal CubeRefCacheEntry[] Entries;
internal void Add(int index, int item)
{
Entries[0].Index = index;
Entries[0].Item = item;
}
}
}
}
This snippet "typically" fails within a minute. 此片段“通常”在一分钟内失败。
UPDATE: It should probably be run in 64-bit. 更新:它可能应该以64位运行。 If compiled with 'Any CPU', the issue takes a lot longer to reproduce. 如果使用“任何CPU”编译,则问题需要更长时间才能重现。
UPDATE2: usings I have: UPDATE2:使用我有:
The original Github issue ( https://github.com/dotnet/corefx/issues/33157 ) has been closed as a duplicate of https://github.com/dotnet/coreclr/issues/20690 . 最初的Github问题( https://github.com/dotnet/corefx/issues/33157 )已作为https://github.com/dotnet/coreclr/issues/20690的副本关闭。 Apparently, this is a known issue that has been fixed in .NET 4.8
. 显然,这是一个已在.NET 4.8
修复的已知问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.