From 01fd182471a4a06c5bdfb3184c4559fb8929bfd3 Mon Sep 17 00:00:00 2001 From: Alex Brainman Date: Thu, 9 Oct 2014 16:52:28 +1100 Subject: runtime: handle all windows exception Fixes issue 8006. LGTM=rsc R=golang-codereviews, rsc CC=golang-codereviews https://codereview.appspot.com/145150043 --- src/runtime/sys_windows_amd64.s | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/runtime/sys_windows_amd64.s') diff --git a/src/runtime/sys_windows_amd64.s b/src/runtime/sys_windows_amd64.s index 05750398e..e6190ce68 100644 --- a/src/runtime/sys_windows_amd64.s +++ b/src/runtime/sys_windows_amd64.s @@ -99,6 +99,7 @@ TEXT runtime·setlasterror(SB),NOSPLIT,$0 // Called by Windows as a Vectored Exception Handler (VEH). // First argument is pointer to struct containing // exception record and context pointers. +// Handler function is stored in AX. // Return 0 for 'not handled', -1 for handled. TEXT runtime·sigtramp(SB),NOSPLIT,$0-0 // CX: PEXCEPTION_POINTERS ExceptionInfo @@ -116,6 +117,8 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$0-0 MOVQ R14, 32(SP) MOVQ R15, 88(SP) + MOVQ AX, R15 // save handler address + // find g get_tls(DX) CMPQ DX, $0 @@ -157,11 +160,10 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$0-0 sigtramp_g0: MOVQ 0(CX), BX // ExceptionRecord* MOVQ 8(CX), CX // Context* - // call sighandler(ExceptionRecord*, Context*, G*) MOVQ BX, 0(SP) MOVQ CX, 8(SP) MOVQ DX, 16(SP) - CALL runtime·sighandler(SB) + CALL R15 // call handler // AX is set to report result back to Windows MOVL 24(SP), AX @@ -187,6 +189,18 @@ done: RET +TEXT runtime·exceptiontramp(SB),NOSPLIT,$0 + MOVQ $runtime·exceptionhandler(SB), AX + JMP runtime·sigtramp(SB) + +TEXT runtime·firstcontinuetramp(SB),NOSPLIT,$0-0 + MOVQ $runtime·firstcontinuehandler(SB), AX + JMP runtime·sigtramp(SB) + +TEXT runtime·lastcontinuetramp(SB),NOSPLIT,$0-0 + MOVQ $runtime·lastcontinuehandler(SB), AX + JMP runtime·sigtramp(SB) + TEXT runtime·ctrlhandler(SB),NOSPLIT,$8 MOVQ CX, 16(SP) // spill MOVQ $runtime·ctrlhandler1(SB), CX -- cgit v1.2.1 From 76b3936b738289481b81b6a520c4f03aef6afcf1 Mon Sep 17 00:00:00 2001 From: Alex Brainman Date: Thu, 9 Oct 2014 17:24:34 +1100 Subject: undo CL 145150043 / 8b3d26697b8d That was complete failure - builders are broken, but original cl worked fine on my system. I will need access to builders to test this change properly. ??? original CL description runtime: handle all windows exception Fixes issue 8006. LGTM=rsc R=golang-codereviews, rsc CC=golang-codereviews https://codereview.appspot.com/145150043 ??? TBR=rsc R=golang-codereviews CC=golang-codereviews https://codereview.appspot.com/154180043 --- src/runtime/sys_windows_amd64.s | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'src/runtime/sys_windows_amd64.s') diff --git a/src/runtime/sys_windows_amd64.s b/src/runtime/sys_windows_amd64.s index e6190ce68..05750398e 100644 --- a/src/runtime/sys_windows_amd64.s +++ b/src/runtime/sys_windows_amd64.s @@ -99,7 +99,6 @@ TEXT runtime·setlasterror(SB),NOSPLIT,$0 // Called by Windows as a Vectored Exception Handler (VEH). // First argument is pointer to struct containing // exception record and context pointers. -// Handler function is stored in AX. // Return 0 for 'not handled', -1 for handled. TEXT runtime·sigtramp(SB),NOSPLIT,$0-0 // CX: PEXCEPTION_POINTERS ExceptionInfo @@ -117,8 +116,6 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$0-0 MOVQ R14, 32(SP) MOVQ R15, 88(SP) - MOVQ AX, R15 // save handler address - // find g get_tls(DX) CMPQ DX, $0 @@ -160,10 +157,11 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$0-0 sigtramp_g0: MOVQ 0(CX), BX // ExceptionRecord* MOVQ 8(CX), CX // Context* + // call sighandler(ExceptionRecord*, Context*, G*) MOVQ BX, 0(SP) MOVQ CX, 8(SP) MOVQ DX, 16(SP) - CALL R15 // call handler + CALL runtime·sighandler(SB) // AX is set to report result back to Windows MOVL 24(SP), AX @@ -189,18 +187,6 @@ done: RET -TEXT runtime·exceptiontramp(SB),NOSPLIT,$0 - MOVQ $runtime·exceptionhandler(SB), AX - JMP runtime·sigtramp(SB) - -TEXT runtime·firstcontinuetramp(SB),NOSPLIT,$0-0 - MOVQ $runtime·firstcontinuehandler(SB), AX - JMP runtime·sigtramp(SB) - -TEXT runtime·lastcontinuetramp(SB),NOSPLIT,$0-0 - MOVQ $runtime·lastcontinuehandler(SB), AX - JMP runtime·sigtramp(SB) - TEXT runtime·ctrlhandler(SB),NOSPLIT,$8 MOVQ CX, 16(SP) // spill MOVQ $runtime·ctrlhandler1(SB), CX -- cgit v1.2.1 From 1e77469a67f3a9905a43aaa0f2c189c7bcd1e558 Mon Sep 17 00:00:00 2001 From: Alex Brainman Date: Wed, 15 Oct 2014 11:11:11 +1100 Subject: runtime: handle all windows exception (second attempt) includes undo of 22318cd31d7d and also: - always use SetUnhandledExceptionFilter on windows-386; - crash when receive EXCEPTION_BREAKPOINT in exception handler. Fixes issue 8006. LGTM=rsc R=golang-codereviews, rsc CC=golang-codereviews https://codereview.appspot.com/155360043 --- src/runtime/sys_windows_amd64.s | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/runtime/sys_windows_amd64.s') diff --git a/src/runtime/sys_windows_amd64.s b/src/runtime/sys_windows_amd64.s index 05750398e..e6190ce68 100644 --- a/src/runtime/sys_windows_amd64.s +++ b/src/runtime/sys_windows_amd64.s @@ -99,6 +99,7 @@ TEXT runtime·setlasterror(SB),NOSPLIT,$0 // Called by Windows as a Vectored Exception Handler (VEH). // First argument is pointer to struct containing // exception record and context pointers. +// Handler function is stored in AX. // Return 0 for 'not handled', -1 for handled. TEXT runtime·sigtramp(SB),NOSPLIT,$0-0 // CX: PEXCEPTION_POINTERS ExceptionInfo @@ -116,6 +117,8 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$0-0 MOVQ R14, 32(SP) MOVQ R15, 88(SP) + MOVQ AX, R15 // save handler address + // find g get_tls(DX) CMPQ DX, $0 @@ -157,11 +160,10 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$0-0 sigtramp_g0: MOVQ 0(CX), BX // ExceptionRecord* MOVQ 8(CX), CX // Context* - // call sighandler(ExceptionRecord*, Context*, G*) MOVQ BX, 0(SP) MOVQ CX, 8(SP) MOVQ DX, 16(SP) - CALL runtime·sighandler(SB) + CALL R15 // call handler // AX is set to report result back to Windows MOVL 24(SP), AX @@ -187,6 +189,18 @@ done: RET +TEXT runtime·exceptiontramp(SB),NOSPLIT,$0 + MOVQ $runtime·exceptionhandler(SB), AX + JMP runtime·sigtramp(SB) + +TEXT runtime·firstcontinuetramp(SB),NOSPLIT,$0-0 + MOVQ $runtime·firstcontinuehandler(SB), AX + JMP runtime·sigtramp(SB) + +TEXT runtime·lastcontinuetramp(SB),NOSPLIT,$0-0 + MOVQ $runtime·lastcontinuehandler(SB), AX + JMP runtime·sigtramp(SB) + TEXT runtime·ctrlhandler(SB),NOSPLIT,$8 MOVQ CX, 16(SP) // spill MOVQ $runtime·ctrlhandler1(SB), CX -- cgit v1.2.1