-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> Auto-Submit: Michael Pratt <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Michael Pratt <[email protected]> Run-TryBot: Quim Muntal <[email protected]> Reviewed-by: David Chase <[email protected]>
- Loading branch information
Showing
5 changed files
with
147 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
) | ||
|
||
func main() { | ||
dll := syscall.MustLoadDLL("veh.dll") | ||
RaiseExcept := dll.MustFindProc("RaiseExcept") | ||
RaiseNoExcept := dll.MustFindProc("RaiseNoExcept") | ||
ThreadRaiseExcept := dll.MustFindProc("ThreadRaiseExcept") | ||
ThreadRaiseNoExcept := dll.MustFindProc("ThreadRaiseNoExcept") | ||
|
||
thread := len(os.Args) > 1 && os.Args[1] == "thread" | ||
if !thread { | ||
RaiseExcept.Call() | ||
RaiseNoExcept.Call() | ||
} else { | ||
ThreadRaiseExcept.Call() | ||
ThreadRaiseNoExcept.Call() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//go:build ignore | ||
|
||
#include <windows.h> | ||
|
||
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); | ||
} |