Skip to content

Commit c6d550a

Browse files
committed
runtime: increase g0 stack size in non-cgo case
Currently, for non-cgo programs, the g0 stack size is 8 KiB on most platforms. With PGO which could cause aggressive inlining in the runtime, the runtime stack frames are larger and could overflow the 8 KiB g0 stack. Increase it to 16 KiB. This is only one per OS thread, so it shouldn't increase memory use much. Fixes #62120. Fixes #62489. Change-Id: I565b154517021f1fd849424dafc3f0f26a755cac Reviewed-on: https://go-review.googlesource.com/c/go/+/526995 Reviewed-by: Michael Pratt <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 2b3c1c5 commit c6d550a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/runtime/proc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,7 @@ func mstart0() {
15421542
// but is somewhat arbitrary.
15431543
size := gp.stack.hi
15441544
if size == 0 {
1545-
size = 8192 * sys.StackGuardMultiplier
1545+
size = 16384 * sys.StackGuardMultiplier
15461546
}
15471547
gp.stack.hi = uintptr(noescape(unsafe.Pointer(&size)))
15481548
gp.stack.lo = gp.stack.hi - size + 1024
@@ -1938,7 +1938,7 @@ func allocm(pp *p, fn func(), id int64) *m {
19381938
if iscgo || mStackIsSystemAllocated() {
19391939
mp.g0 = malg(-1)
19401940
} else {
1941-
mp.g0 = malg(8192 * sys.StackGuardMultiplier)
1941+
mp.g0 = malg(16384 * sys.StackGuardMultiplier)
19421942
}
19431943
mp.g0.m = mp
19441944

0 commit comments

Comments
 (0)