diff --git a/tools/run-tests/windows-passing.txt b/tools/run-tests/windows-passing.txt index 05d794a3..bbb37a22 100644 --- a/tools/run-tests/windows-passing.txt +++ b/tools/run-tests/windows-passing.txt @@ -75574,6 +75574,7 @@ unmanaged-configpath dllimport-preload dllimport-cctor valist +seh # unreliable: x86.thread-exit MonoTests.System.Threading.Tasks.TaskTests:DoubleWaitTest diff --git a/tools/run-tests/wine-failing.txt b/tools/run-tests/wine-failing.txt index dcfccce7..4c9a2678 100644 --- a/tools/run-tests/wine-failing.txt +++ b/tools/run-tests/wine-failing.txt @@ -1752,6 +1752,7 @@ mixedmode-dllimport-usedlldirectory MonoTests.System.ServiceModel.CallbackBehaviorAttributeTest:CallbackExample2 MonoTests.System.ServiceModel.CallbackBehaviorAttributeTest:ConcurrencyModeSingleAndCallbackInsideServiceMethod unmanaged-configpath +seh # definitely unreliable: delegate2 x86_64.MonoTests.System.Threading.ThreadLocalTests:DisposeOnThreadExit diff --git a/tools/tests/seh.cs b/tools/tests/seh.cs new file mode 100644 index 00000000..306f2c7a --- /dev/null +++ b/tools/tests/seh.cs @@ -0,0 +1,57 @@ +using System; +using System.Runtime.ExceptionServices; +using System.Runtime.InteropServices; +using System.Text; + +static class TestSeh +{ + [DllImport("kernel32")] + extern static void RaiseException(uint code, int flags, int argc, [In] IntPtr[] arguments); + + [DllImport("msvcrt", CallingConvention=CallingConvention.Cdecl)] + extern static IntPtr memcpy(IntPtr dest, IntPtr src, IntPtr count); + + [HandleProcessCorruptedStateExceptions] + public static int Main() + { + bool got_exception = false; + try + { + RaiseException(0x88888888, 0, 0, null); + } + catch (SEHException) + { + Console.WriteLine("1"); + got_exception = true; + } + if (!got_exception) + return 1; + + got_exception = false; + try + { + RaiseException(0xc0000017, 0, 0, null); + } + catch (OutOfMemoryException) + { + Console.WriteLine("2"); + got_exception = true; + } + if (!got_exception) + return 2; + + got_exception = false; + try + { + memcpy(IntPtr.Zero, IntPtr.Zero, new IntPtr(1)); + } + catch (AccessViolationException) + { + Console.WriteLine("3"); + got_exception = true; + } + if (!got_exception) + return 3; + return 0; + } +} diff --git a/tools/tests/tests.make b/tools/tests/tests.make index 565dba8e..f52a86a6 100644 --- a/tools/tests/tests.make +++ b/tools/tests/tests.make @@ -21,6 +21,7 @@ TEST_CS_EXE_SRCS = \ rcw-visible.cs \ releasebadptr.cs \ runtimeinterface.cs \ + seh.cs \ thread-exit-bk.cs \ unmanaged-configpath.cs \ valist.cs \