From 6fe3ccd74c4bf53552da3d9f59463a8a291f59db Mon Sep 17 00:00:00 2001 From: qmuntal Date: Fri, 14 Oct 2022 17:30:45 +0200 Subject: runtime: ignore exceptions from non-Go threads on windows arm/arm64 If there is no current G while handling an exception it means the exception was originated in a non-Go thread. The best we can do is ignore the exception and let it flow through other vectored and structured error handlers. I've removed badsignal2 from sigtramp because we can't really know if the signal is bad or not, it might be handled later in the chain. Fixes #50877 Updates #56082 Change-Id: Ica159eb843629986d1fb5482f0b59a9c1ed91698 Reviewed-on: https://go-review.googlesource.com/c/go/+/442896 Reviewed-by: Alex Brainman Auto-Submit: Michael Pratt TryBot-Result: Gopher Robot Reviewed-by: Michael Pratt Run-TryBot: Quim Muntal Reviewed-by: David Chase --- src/runtime/testdata/testwinlibthrow/veh.cpp | 53 ++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/runtime/testdata/testwinlibthrow/veh.cpp (limited to 'src/runtime/testdata/testwinlibthrow/veh.cpp') diff --git a/src/runtime/testdata/testwinlibthrow/veh.cpp b/src/runtime/testdata/testwinlibthrow/veh.cpp new file mode 100644 index 0000000000..ed7015a064 --- /dev/null +++ b/src/runtime/testdata/testwinlibthrow/veh.cpp @@ -0,0 +1,53 @@ +//go:build ignore + +#include + +extern "C" __declspec(dllexport) +void RaiseExcept(void) +{ + try + { + RaiseException(42, 0, 0, 0); + } + catch (...) + { + } +} + +extern "C" __declspec(dllexport) +void RaiseNoExcept(void) +{ + RaiseException(42, 0, 0, 0); +} + +static DWORD WINAPI ThreadRaiser(void* Context) +{ + if (Context) + RaiseExcept(); + else + RaiseNoExcept(); + return 0; +} + +static void ThreadRaiseXxx(int except) +{ + static int dummy; + HANDLE thread = CreateThread(0, 0, ThreadRaiser, except ? &dummy : 0, 0, 0); + if (0 != thread) + { + WaitForSingleObject(thread, INFINITE); + CloseHandle(thread); + } +} + +extern "C" __declspec(dllexport) +void ThreadRaiseExcept(void) +{ + ThreadRaiseXxx(1); +} + +extern "C" __declspec(dllexport) +void ThreadRaiseNoExcept(void) +{ + ThreadRaiseXxx(0); +} -- cgit v1.3