From my practice, HandleProcessCorruptedStateExceptions not works for StackOverflow exception but OK for AccessViolationException.
AccessViolationException from this post which is caught:
public class Test
{
public static void Main(string[] args)
{
Wtf();
}
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
private static void Wtf()
{
try
{
IntPtr ptr = new IntPtr(1000);
Marshal.StructureToPtr(1000, ptr, true);
}
catch (Exception e)
{
Environment.Exit(1);
}
}
}
StackOverflow exception written by myself, which catch nothing.
public class Test
{
public static void Main(string[] args)
{
Wtf();
}
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
private static void Wtf()
{
try
{
F();
}
catch (Exception e)
{
Environment.Exit(1);
}
}
private static void F()
{
F();
}
}
Could someone explain this? Thanks!