Commit 77f4571f authored by Daniel Theophanes's avatar Daniel Theophanes Committed by Alex Brainman

runtime: do not use AddVectoredContinueHandler on Windows XP/2003.

When Windows Error Reporting dialog is disabled on amd64
Windows XP or 2003, the continue handler does not fire. Newer
versions work correctly regardless of WER.

Fixes #10162

Change-Id: I84ea36ee188b34d1421a8db6231223cf61b4111b
Reviewed-on: https://go-review.googlesource.com/8165Reviewed-by: default avatarAlex Brainman <alex.brainman@gmail.com>
parent ca98dd77
...@@ -26,6 +26,7 @@ import ( ...@@ -26,6 +26,7 @@ import (
//go:cgo_import_dynamic runtime._GetStdHandle GetStdHandle%1 "kernel32.dll" //go:cgo_import_dynamic runtime._GetStdHandle GetStdHandle%1 "kernel32.dll"
//go:cgo_import_dynamic runtime._GetSystemInfo GetSystemInfo%1 "kernel32.dll" //go:cgo_import_dynamic runtime._GetSystemInfo GetSystemInfo%1 "kernel32.dll"
//go:cgo_import_dynamic runtime._GetThreadContext GetThreadContext%2 "kernel32.dll" //go:cgo_import_dynamic runtime._GetThreadContext GetThreadContext%2 "kernel32.dll"
//go:cgo_import_dynamic runtime._GetVersion GetVersion%0 "kernel32.dll"
//go:cgo_import_dynamic runtime._LoadLibraryW LoadLibraryW%1 "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._LoadLibraryA LoadLibraryA%1 "kernel32.dll"
//go:cgo_import_dynamic runtime._NtWaitForSingleObject NtWaitForSingleObject%3 "ntdll.dll" //go:cgo_import_dynamic runtime._NtWaitForSingleObject NtWaitForSingleObject%3 "ntdll.dll"
...@@ -67,6 +68,7 @@ var ( ...@@ -67,6 +68,7 @@ var (
_GetStdHandle, _GetStdHandle,
_GetSystemInfo, _GetSystemInfo,
_GetThreadContext, _GetThreadContext,
_GetVersion,
_LoadLibraryW, _LoadLibraryW,
_LoadLibraryA, _LoadLibraryA,
_NtWaitForSingleObject, _NtWaitForSingleObject,
...@@ -148,6 +150,12 @@ func disableWER() { ...@@ -148,6 +150,12 @@ func disableWER() {
stdcall1(_SetErrorMode, uintptr(errormode)|SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX|SEM_NOOPENFILEERRORBOX) stdcall1(_SetErrorMode, uintptr(errormode)|SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX|SEM_NOOPENFILEERRORBOX)
} }
func getVersion() (major, minor byte) {
v := uint32(stdcall0(_GetVersion))
low := uint16(v)
return byte(low), byte(low >> 8)
}
func osinit() { func osinit() {
setBadSignalMsg() setBadSignalMsg()
...@@ -157,10 +165,15 @@ func osinit() { ...@@ -157,10 +165,15 @@ func osinit() {
externalthreadhandlerp = funcPC(externalthreadhandler) externalthreadhandlerp = funcPC(externalthreadhandler)
major, _ := getVersion()
stdcall2(_AddVectoredExceptionHandler, 1, funcPC(exceptiontramp)) stdcall2(_AddVectoredExceptionHandler, 1, funcPC(exceptiontramp))
if _AddVectoredContinueHandler == nil || unsafe.Sizeof(&_AddVectoredContinueHandler) == 4 { if _AddVectoredContinueHandler == nil || unsafe.Sizeof(&_AddVectoredContinueHandler) == 4 || major < 6 {
// use SetUnhandledExceptionFilter for windows-386 or // use SetUnhandledExceptionFilter for windows-386 or
// if VectoredContinueHandler is unavailable. // if VectoredContinueHandler is unavailable or
// if running windows-amd64 v5. V5 appears to fail to
// call the continue handlers if windows error reporting dialog
// is disabled.
// note: SetUnhandledExceptionFilter handler won't be called, if debugging. // note: SetUnhandledExceptionFilter handler won't be called, if debugging.
stdcall1(_SetUnhandledExceptionFilter, funcPC(lastcontinuetramp)) stdcall1(_SetUnhandledExceptionFilter, funcPC(lastcontinuetramp))
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment