mirror of
https://github.com/golang/go
synced 2024-11-17 20:54:48 -07:00
runtime: fix TestVectoredHandlerExceptionInNonGoThread
This test is failing on the windows-arm64-10 builder https://build.golang.org/log/c161c86be1af83c349ee02c1b12eff5828818f50. It is not failing on windows-arm64-11, so I guess it has something to do with the compiler. This CL simplifies the test so is easier to build. Change-Id: I6e0e1cf237277628f8ebf892c70ab54cd0077680 Reviewed-on: https://go-review.googlesource.com/c/go/+/444438 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
parent
72c58fb771
commit
160bb0e66b
@ -23,14 +23,14 @@ func TestVectoredHandlerExceptionInNonGoThread(t *testing.T) {
|
||||
}
|
||||
testenv.MustHaveGoBuild(t)
|
||||
testenv.MustHaveCGO(t)
|
||||
testenv.MustHaveExecPath(t, "g++")
|
||||
testenv.MustHaveExecPath(t, "gcc")
|
||||
testprog.Lock()
|
||||
defer testprog.Unlock()
|
||||
dir := t.TempDir()
|
||||
|
||||
// build c program
|
||||
dll := filepath.Join(dir, "veh.dll")
|
||||
cmd := exec.Command("g++", "-shared", "-o", dll, "testdata/testwinlibthrow/veh.cpp", "-static", "-lstdc++")
|
||||
cmd := exec.Command("gcc", "-shared", "-o", dll, "testdata/testwinlibthrow/veh.c")
|
||||
out, err := testenv.CleanCmdEnv(cmd).CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to build c exe: %s\n%s", err, out)
|
||||
|
4
src/runtime/testdata/testwinlibthrow/main.go
vendored
4
src/runtime/testdata/testwinlibthrow/main.go
vendored
@ -7,17 +7,13 @@ import (
|
||||
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
26
src/runtime/testdata/testwinlibthrow/veh.c
vendored
Normal file
26
src/runtime/testdata/testwinlibthrow/veh.c
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
//go:build ignore
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
__declspec(dllexport)
|
||||
void RaiseNoExcept(void)
|
||||
{
|
||||
RaiseException(42, 0, 0, 0);
|
||||
}
|
||||
|
||||
static DWORD WINAPI ThreadRaiser(void* Context)
|
||||
{
|
||||
RaiseNoExcept();
|
||||
return 0;
|
||||
}
|
||||
|
||||
__declspec(dllexport)
|
||||
void ThreadRaiseNoExcept(void)
|
||||
{
|
||||
HANDLE thread = CreateThread(0, 0, ThreadRaiser, 0, 0, 0);
|
||||
if (0 != thread)
|
||||
{
|
||||
WaitForSingleObject(thread, INFINITE);
|
||||
CloseHandle(thread);
|
||||
}
|
||||
}
|
53
src/runtime/testdata/testwinlibthrow/veh.cpp
vendored
53
src/runtime/testdata/testwinlibthrow/veh.cpp
vendored
@ -1,53 +0,0 @@
|
||||
//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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user