1
0
mirror of https://github.com/golang/go synced 2024-11-11 18:51:37 -07: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 misc/cgo/fortran: convert to Go test 2022-10-17 15:15:37 +00:00
gmp all: gofmt main repo 2022-04-11 16:34:30 +00:00
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 cmd/cgo: retain original file paths in godefs generated comment 2022-04-03 07:18:10 +00:00
testplugin cmd/compile: make jump table symbol local 2022-07-22 20:12:19 +00:00
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 all: gofmt more (but vendor, testdata, and top-level test directories) 2021-08-13 20:45:17 +00:00
testsovar all: gofmt more (but vendor, testdata, and top-level test directories) 2021-08-13 20:45:17 +00:00
testtls all: gofmt more (but vendor, testdata, and top-level test directories) 2021-08-13 20:45:17 +00:00