1
0
mirror of https://github.com/golang/go synced 2024-11-23 11:10:04 -07:00
go/misc
Cherry Mui 443eb9757c runtime: get a better g0 stack bound in needm
Currently, when C calls into Go the first time, we grab an M
using needm, which sets m.g0's stack bounds using the SP. We don't
know how big the stack is, so we simply assume 32K. Previously,
when the Go function returns to C, we drop the M, and the next
time C calls into Go, we put a new stack bound on the g0 based on
the current SP. After CL 392854, we don't drop the M, and the next
time C calls into Go, we reuse the same g0, without recomputing
the stack bounds. If the C code uses quite a bit of stack space
before calling into Go, the SP may be well below the 32K stack
bound we assumed, so the runtime thinks the g0 stack overflows.

This CL makes needm get a more accurate stack bound from
pthread. (In some platforms this may still be a guess as we don't
know exactly where we are in the C stack), but it is probably
better than simply assuming 32K.

For #59294.

Change-Id: Ie52a8f931e0648d8753e4c1dbe45468b8748b527
Reviewed-on: https://go-review.googlesource.com/c/go/+/479915
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-03-30 23:23:55 +00:00
..
android misc: use strings.Builder 2022-09-06 15:44:25 +00:00
arm
cgo runtime: get a better g0 stack bound in needm 2023-03-30 23:23:55 +00:00
chrome/gophertool
ios all: gofmt main repo 2022-04-11 16:34:30 +00:00
linkcheck all: use bytes.Cut, strings.Cut 2021-10-06 15:53:04 +00:00
reboot misc/reboot: overlay $GOROOT/lib in temporary goroot 2023-01-18 01:53:44 +00:00
swig
wasm all: implement wasmimport directive 2023-03-02 05:28:55 +00:00
editors
go.mod misc: update go.mod to 1.21 2023-01-26 16:55:59 +00:00