1
0
mirror of https://github.com/golang/go synced 2024-09-29 08:14:29 -06:00
go/misc/cgo
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
..
errors runtime: reimplement GODEBUG=cgocheck=2 as a GOEXPERIMENT 2023-02-16 00:16:24 +00:00
fortran
gmp
life misc/cgo/{life,stdio}: remove reliance on test/run.go 2023-02-28 01:11:11 +00:00
nocgo
stdio misc/cgo/{life,stdio}: remove reliance on test/run.go 2023-02-28 01:11:11 +00:00
test runtime/cgo: store M for C-created thread in pthread key 2023-03-24 16:00:24 +00:00
testcarchive runtime: get a better g0 stack bound in needm 2023-03-30 23:23:55 +00:00
testcshared misc/cgo/testcshared: reapply CL 451816 2022-11-22 02:27:05 +00:00
testgodefs
testplugin
testsanitizers runtime/cgo: add tsan sync for traceback function 2023-03-08 20:11:59 +00:00
testshared cmd/compile: re-compile instantiated generic methods in linkshared mode 2023-03-22 04:04:11 +00:00
testso
testsovar
testtls