From 57205f91fe6f7cecbf0b7aad0d90d2f81270b1e8 Mon Sep 17 00:00:00 2001 From: go101 Date: Fri, 2 Jul 2021 03:58:32 -0400 Subject: [PATCH] more readable --- src/runtime/stack.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/runtime/stack.go b/src/runtime/stack.go index 0ca7f7440c..6e0d157630 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -1064,7 +1064,9 @@ func newstack() { // recheck the bounds on return.) if f := findfunc(gp.sched.pc); f.valid() { max := uintptr(funcMaxSPDelta(f)) - for newsize-(gp.stack.hi-gp.sched.sp) < max+_StackGuard { + needed := max + _StackGuard + used := gp.stack.hi - gp.sched.sp + for newsize-used < needed { newsize *= 2 } }