From 3aba7a7d6e436cddc1c6f134dd13a82a980e9973 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 11 Sep 2020 13:05:30 +0200 Subject: go: update to 1.15.2 Signed-off-by: Jason A. Donenfeld --- go-patches/highres-timer.patch | 6 +- go-patches/no-ctrlc-handler.patch | 150 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 148 insertions(+), 8 deletions(-) (limited to 'go-patches') diff --git a/go-patches/highres-timer.patch b/go-patches/highres-timer.patch index cdf47939..87dd6b17 100644 --- a/go-patches/highres-timer.patch +++ b/go-patches/highres-timer.patch @@ -1,4 +1,4 @@ -From 0b802790a76f4781c83e8fd400857bcd365b6a23 Mon Sep 17 00:00:00 2001 +From 2975b381dc3f559a2eef875582d73cec00ab6b17 Mon Sep 17 00:00:00 2001 From: Alex Brainman Date: Sun, 19 Jul 2020 16:06:48 +1000 Subject: [PATCH] runtime: use CreateWaitableTimerEx to implement usleep @@ -147,7 +147,7 @@ Change-Id: I5b97ba58289c088c17c05292e12e45285c467eae --- diff --git a/src/runtime/os_windows.go b/src/runtime/os_windows.go -index a584ada..5ca492b 100644 +index a62e941..46f4a23 100644 --- a/src/runtime/os_windows.go +++ b/src/runtime/os_windows.go @@ -21,6 +21,7 @@ @@ -212,7 +212,7 @@ index a584ada..5ca492b 100644 + +func initHighResTimer() { + if GOARCH == "arm" { -+ // TODO: Not implemented, if we running on arm. ++ // TODO: Not yet implemented. + return + } + h := createHighResTimer() diff --git a/go-patches/no-ctrlc-handler.patch b/go-patches/no-ctrlc-handler.patch index e8c5b6fc..157ed88f 100644 --- a/go-patches/no-ctrlc-handler.patch +++ b/go-patches/no-ctrlc-handler.patch @@ -1,7 +1,142 @@ -From c0dded04f7ded5048b44200078a1f723f5e1bcc1 Mon Sep 17 00:00:00 2001 -From: Jason A. Donenfeld +From 8bc7bff3bff8f61312f8d2307cfe2e433d356c31 Mon Sep 17 00:00:00 2001 +From: "Jason A. Donenfeld" +Date: Fri, 11 Sep 2020 13:04:11 +0200 +Subject: [PATCH 1/2] Revert "[release-branch.go1.15] runtime: detect services + in signal handler" + +This reverts commit b1253d24e159129c778377c3a2a0bde15904a417. +--- + src/runtime/os_windows.go | 73 +++------------------------------------ + 1 file changed, 4 insertions(+), 69 deletions(-) + +diff --git a/src/runtime/os_windows.go b/src/runtime/os_windows.go +index 769197db46..a584ada702 100644 +--- a/src/runtime/os_windows.go ++++ b/src/runtime/os_windows.go +@@ -36,10 +36,7 @@ const ( + //go:cgo_import_dynamic runtime._SetThreadContext SetThreadContext%2 "kernel32.dll" + //go:cgo_import_dynamic runtime._LoadLibraryW LoadLibraryW%1 "kernel32.dll" + //go:cgo_import_dynamic runtime._LoadLibraryA LoadLibraryA%1 "kernel32.dll" +-//go:cgo_import_dynamic runtime._OpenProcess OpenProcess%3 "kernel32.dll" + //go:cgo_import_dynamic runtime._PostQueuedCompletionStatus PostQueuedCompletionStatus%4 "kernel32.dll" +-//go:cgo_import_dynamic runtime._ProcessIdToSessionId ProcessIdToSessionId%2 "kernel32.dll" +-//go:cgo_import_dynamic runtime._QueryFullProcessImageNameA QueryFullProcessImageNameA%4 "kernel32.dll" + //go:cgo_import_dynamic runtime._ResumeThread ResumeThread%1 "kernel32.dll" + //go:cgo_import_dynamic runtime._SetConsoleCtrlHandler SetConsoleCtrlHandler%2 "kernel32.dll" + //go:cgo_import_dynamic runtime._SetErrorMode SetErrorMode%1 "kernel32.dll" +@@ -87,10 +84,7 @@ var ( + _SetThreadContext, + _LoadLibraryW, + _LoadLibraryA, +- _OpenProcess, + _PostQueuedCompletionStatus, +- _ProcessIdToSessionId, +- _QueryFullProcessImageNameA, + _QueryPerformanceCounter, + _QueryPerformanceFrequency, + _ResumeThread, +@@ -134,8 +128,7 @@ var ( + // Load ntdll.dll manually during startup, otherwise Mingw + // links wrong printf function to cgo executable (see issue + // 12030 for details). +- _NtWaitForSingleObject stdFunction +- _NtQueryInformationProcess stdFunction ++ _NtWaitForSingleObject stdFunction + + // These are from non-kernel32.dll, so we prefer to LoadLibraryEx them. + _timeBeginPeriod, +@@ -262,7 +255,6 @@ func loadOptionalSyscalls() { + throw("ntdll.dll not found") + } + _NtWaitForSingleObject = windowsFindfunc(n32, []byte("NtWaitForSingleObject\000")) +- _NtQueryInformationProcess = windowsFindfunc(n32, []byte("NtQueryInformationProcess\000")) + + if GOARCH == "arm" { + _QueryPerformanceCounter = windowsFindfunc(k32, []byte("QueryPerformanceCounter\000")) +@@ -1003,63 +995,6 @@ func usleep(us uint32) { + onosstack(usleep2Addr, 10*us) + } + +-// isWindowsService returns whether the process is currently executing as a +-// Windows service. The below technique looks a bit hairy, but it's actually +-// exactly what the .NET framework does for the similarly named function: +-// https://github.com/dotnet/extensions/blob/f4066026ca06984b07e90e61a6390ac38152ba93/src/Hosting/WindowsServices/src/WindowsServiceHelpers.cs#L26-L31 +-// Specifically, it looks up whether the parent process has session ID zero +-// and is called "services". +-func isWindowsService() bool { +- const ( +- _CURRENT_PROCESS = ^uintptr(0) +- _PROCESS_QUERY_LIMITED_INFORMATION = 0x1000 +- ) +- // pbi is a PROCESS_BASIC_INFORMATION struct, where we just care about +- // the 6th pointer inside of it, which contains the pid of the process +- // parent: +- // https://github.com/wine-mirror/wine/blob/42cb7d2ad1caba08de235e6319b9967296b5d554/include/winternl.h#L1294 +- var pbi [6]uintptr +- var pbiLen uint32 +- err := stdcall5(_NtQueryInformationProcess, _CURRENT_PROCESS, 0, uintptr(unsafe.Pointer(&pbi[0])), uintptr(unsafe.Sizeof(pbi)), uintptr(unsafe.Pointer(&pbiLen))) +- if err != 0 { +- return false +- } +- var psid uint32 +- err = stdcall2(_ProcessIdToSessionId, pbi[5], uintptr(unsafe.Pointer(&psid))) +- if err == 0 || psid != 0 { +- return false +- } +- pproc := stdcall3(_OpenProcess, _PROCESS_QUERY_LIMITED_INFORMATION, 0, pbi[5]) +- if pproc == 0 { +- return false +- } +- defer stdcall1(_CloseHandle, pproc) +- // exeName gets the path to the executable image of the parent process +- var exeName [261]byte +- exeNameLen := uint32(len(exeName) - 1) +- err = stdcall4(_QueryFullProcessImageNameA, pproc, 0, uintptr(unsafe.Pointer(&exeName[0])), uintptr(unsafe.Pointer(&exeNameLen))) +- if err == 0 || exeNameLen == 0 { +- return false +- } +- servicesLower := "services.exe" +- servicesUpper := "SERVICES.EXE" +- i := int(exeNameLen) - 1 +- j := len(servicesLower) - 1 +- if i < j { +- return false +- } +- for { +- if j == -1 { +- return i == -1 || exeName[i] == '\\' +- } +- if exeName[i] != servicesLower[j] && exeName[i] != servicesUpper[j] { +- return false +- } +- i-- +- j-- +- } +-} +- + func ctrlhandler1(_type uint32) uint32 { + var s uint32 + +@@ -1075,9 +1010,9 @@ func ctrlhandler1(_type uint32) uint32 { + if sigsend(s) { + return 1 + } +- if !islibrary && !isarchive && !isWindowsService() { +- // Only exit the program if we don't have a DLL or service. +- // See https://golang.org/issues/35965 and https://golang.org/issues/40167 ++ if !islibrary && !isarchive { ++ // Only exit the program if we don't have a DLL. ++ // See https://golang.org/issues/35965. + exit(2) // SIGINT, SIGTERM, etc + } + return 0 +-- +2.28.0 + +From 84cc2046962e754af08f99327561be2e979eaf16 Mon Sep 17 00:00:00 2001 +From: "Jason A. Donenfeld" Date: Tue, 14 Jul 2020 01:41:03 -0600 -Subject: [PATCH] runtime: do not explicitly exit on ctrl handler +Subject: [PATCH 2/2] runtime: do not explicitly exit on ctrl handler The default ctrl+c handler should process exits in situations where it makes sense, like console apps, but not in situations where it doesn't, @@ -25,12 +160,14 @@ TryBot-Result: Gobot Gobot Reviewed-by: Alex Brainman Reviewed-by: Jason A. Donenfeld --- + src/runtime/os_windows.go | 5 ----- + 1 file changed, 5 deletions(-) diff --git a/src/runtime/os_windows.go b/src/runtime/os_windows.go -index a584ada..a62e941 100644 +index a584ada702..a62e941229 100644 --- a/src/runtime/os_windows.go +++ b/src/runtime/os_windows.go -@@ -1010,11 +1010,6 @@ +@@ -1010,11 +1010,6 @@ func ctrlhandler1(_type uint32) uint32 { if sigsend(s) { return 1 } @@ -42,3 +179,6 @@ index a584ada..a62e941 100644 return 0 } +-- +2.28.0 + -- cgit v1.2.3-59-g8ed1b