runtime: fix spurious stack overflow detection

The regabi builders are unhappy about badctxt calling throw
calling systemstack calling gosave_systemstack_switch calling
badctxt, all nosplit, repeating. This wouldn't actually happen
since after one systemstack we'd end up on the system stack
and the next one wouldn't call gosave_systemstack_switch at all.

The badctxt call itself is in a very unlikely assertion failure
inside gosave_systemstack_switch.
Keep the assertion check but call runtime.abort instead on failure,
breaking the detected (but not real) cycle.

Change-Id: Iaf5c0fc065783b8c1c6d0f62d848f023a0714b96
Reviewed-on: https://go-review.googlesource.com/c/go/+/294069
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Russ Cox 2021-02-19 05:22:35 -05:00
parent fce2a94d84
commit 49add6ad90
9 changed files with 9 additions and 9 deletions

View File

@ -618,7 +618,7 @@ TEXT gosave_systemstack_switch<>(SB),NOSPLIT,$0
MOVL (g_sched+gobuf_ctxt)(BX), AX
TESTL AX, AX
JZ 2(PC)
CALL runtime·badctxt(SB)
CALL runtime·abort(SB)
POPL BX
POPL AX
RET

View File

@ -677,7 +677,7 @@ TEXT gosave_systemstack_switch<>(SB),NOSPLIT,$0
MOVQ (g_sched+gobuf_ctxt)(R14), R9
TESTQ R9, R9
JZ 2(PC)
CALL runtime·badctxt(SB)
CALL runtime·abort(SB)
RET
// func asmcgocall_no_g(fn, arg unsafe.Pointer)

View File

@ -536,7 +536,7 @@ TEXT gosave_systemstack_switch<>(SB),NOSPLIT|NOFRAME,$0
MOVW (g_sched+gobuf_ctxt)(g), R11
TST R11, R11
B.EQ 2(PC)
BL runtime·badctxt(SB)
BL runtime·abort(SB)
RET
// func asmcgocall_no_g(fn, arg unsafe.Pointer)

View File

@ -875,7 +875,7 @@ TEXT gosave_systemstack_switch<>(SB),NOSPLIT|NOFRAME,$0
// Assert ctxt is zero. See func save.
MOVD (g_sched+gobuf_ctxt)(g), R0
CBZ R0, 2(PC)
CALL runtime·badctxt(SB)
CALL runtime·abort(SB)
RET
// func asmcgocall_no_g(fn, arg unsafe.Pointer)

View File

@ -415,7 +415,7 @@ TEXT gosave_systemstack_switch<>(SB),NOSPLIT|NOFRAME,$0
// Assert ctxt is zero. See func save.
MOVV (g_sched+gobuf_ctxt)(g), R1
BEQ R1, 2(PC)
JAL runtime·badctxt(SB)
JAL runtime·abort(SB)
RET
// func asmcgocall_no_g(fn, arg unsafe.Pointer)

View File

@ -413,7 +413,7 @@ TEXT gosave_systemstack_switch<>(SB),NOSPLIT|NOFRAME,$0
// Assert ctxt is zero. See func save.
MOVW (g_sched+gobuf_ctxt)(g), R1
BEQ R1, 2(PC)
JAL runtime·badctxt(SB)
JAL runtime·abort(SB)
RET
// func asmcgocall(fn, arg unsafe.Pointer) int32

View File

@ -547,7 +547,7 @@ TEXT gosave_systemstack_switch<>(SB),NOSPLIT|NOFRAME,$0
MOVD (g_sched+gobuf_ctxt)(g), R31
CMP R0, R31
BEQ 2(PC)
BL runtime·badctxt(SB)
BL runtime·abort(SB)
RET
#ifdef GOOS_aix

View File

@ -310,7 +310,7 @@ TEXT gosave_systemstack_switch<>(SB),NOSPLIT|NOFRAME,$0
// Assert ctxt is zero. See func save.
MOV (g_sched+gobuf_ctxt)(g), X31
BEQ ZERO, X31, 2(PC)
CALL runtime·badctxt(SB)
CALL runtime·abort(SB)
RET
// func asmcgocall(fn, arg unsafe.Pointer) int32

View File

@ -511,7 +511,7 @@ TEXT gosave_systemstack_switch<>(SB),NOSPLIT|NOFRAME,$0
// Assert ctxt is zero. See func save.
MOVD (g_sched+gobuf_ctxt)(g), R1
CMPBEQ R1, $0, 2(PC)
BL runtime·badctxt(SB)
BL runtime·abort(SB)
RET
// func asmcgocall(fn, arg unsafe.Pointer) int32