aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/objabi/stack.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2022-11-16 12:56:40 -0800
committerKeith Randall <khr@google.com>2022-11-18 16:26:25 +0000
commit893964b9727a3dfcadab75c0f6b3c6b683b9bae0 (patch)
tree612af6c8419229681102fa682c18000e84f5701d /src/cmd/internal/objabi/stack.go
parente18d07ddc5c9005738c3063130f0f5ccf127849e (diff)
downloadgo-893964b9727a3dfcadab75c0f6b3c6b683b9bae0.tar.xz
runtime,cmd/link: increase stack guard space when building with -race
More stuff to do = more stack needed. Bump up the guard space when building with the race detector. Fixes #54291 Change-Id: I701bc8800507921bed568047d35b8f49c26e7df7 Reviewed-on: https://go-review.googlesource.com/c/go/+/451217 Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/cmd/internal/objabi/stack.go')
-rw-r--r--src/cmd/internal/objabi/stack.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/cmd/internal/objabi/stack.go b/src/cmd/internal/objabi/stack.go
index 80bd1c0799..88b4990d5e 100644
--- a/src/cmd/internal/objabi/stack.go
+++ b/src/cmd/internal/objabi/stack.go
@@ -15,17 +15,26 @@ const (
StackSmall = 128
)
-// Initialize StackGuard and StackLimit according to target system.
-var StackGuard = 928*stackGuardMultiplier() + StackSystem
-var StackLimit = StackGuard - StackSystem - StackSmall
+func StackLimit(race bool) int {
+ // This arithmetic must match that in runtime/stack.go:{_StackGuard,_StackLimit}.
+ stackGuard := 928*stackGuardMultiplier(race) + StackSystem
+ stackLimit := stackGuard - StackSystem - StackSmall
+ return stackLimit
+}
// stackGuardMultiplier returns a multiplier to apply to the default
// stack guard size. Larger multipliers are used for non-optimized
// builds that have larger stack frames or for specific targets.
-func stackGuardMultiplier() int {
+func stackGuardMultiplier(race bool) int {
+ // This arithmetic must match that in runtime/internal/sys/consts.go:StackGuardMultiplier.
+ n := 1
// On AIX, a larger stack is needed for syscalls.
if buildcfg.GOOS == "aix" {
- return 2
+ n += 1
+ }
+ // The race build also needs more stack.
+ if race {
+ n += 1
}
- return 1
+ return n
}