]> Cypherpunks repositories - gostls13.git/commit
runtime/cgo: use frame address to set g0 stack bound
authorIan Lance Taylor <iant@golang.org>
Tue, 8 Aug 2023 19:49:48 +0000 (12:49 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 9 Aug 2023 03:13:11 +0000 (03:13 +0000)
commita3ced4a6333dc669359e77004fa3f8a662961cb5
treedb73386b9eff6f4d2550ed82f83150927d2bd5d4
parent2d5ce9b729c0edded841301bd73d68d5e95aa28b
runtime/cgo: use frame address to set g0 stack bound

This extends CL 419434 to all Unix targets. Rather than repeating
the code, pull all the similar code into a single function.

CL 419434 description:

For a cgo binary, at startup we set g0's stack bounds using the
address of a local variable (&size) in a C function x_cgo_init and
the stack size from pthread_attr_getstacksize. Normally, &size is
an address within the current stack frame. However, when  it is
compiled with ASAN, it may be instrumented to __asan_stack_malloc_0
and the address may not live in the current stack frame, causing
the stack bound to be set incorrectly, e.g. lo > hi.

Using __builtin_frame_address(0) to get the stack address instead.

Change-Id: I914a09d32c66a79515b6f700be18c690f3c0c77b
Reviewed-on: https://go-review.googlesource.com/c/go/+/517335
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
30 files changed:
src/runtime/cgo/gcc_darwin_amd64.c
src/runtime/cgo/gcc_darwin_arm64.c
src/runtime/cgo/gcc_dragonfly_amd64.c
src/runtime/cgo/gcc_freebsd_386.c
src/runtime/cgo/gcc_freebsd_amd64.c
src/runtime/cgo/gcc_freebsd_arm.c
src/runtime/cgo/gcc_freebsd_arm64.c
src/runtime/cgo/gcc_freebsd_riscv64.c
src/runtime/cgo/gcc_libinit.c
src/runtime/cgo/gcc_linux_386.c
src/runtime/cgo/gcc_linux_amd64.c
src/runtime/cgo/gcc_linux_arm.c
src/runtime/cgo/gcc_linux_arm64.c
src/runtime/cgo/gcc_linux_loong64.c
src/runtime/cgo/gcc_linux_mips64x.c
src/runtime/cgo/gcc_linux_mipsx.c
src/runtime/cgo/gcc_linux_riscv64.c
src/runtime/cgo/gcc_linux_s390x.c
src/runtime/cgo/gcc_netbsd_386.c
src/runtime/cgo/gcc_netbsd_amd64.c
src/runtime/cgo/gcc_netbsd_arm.c
src/runtime/cgo/gcc_netbsd_arm64.c
src/runtime/cgo/gcc_openbsd_386.c
src/runtime/cgo/gcc_openbsd_amd64.c
src/runtime/cgo/gcc_openbsd_arm.c
src/runtime/cgo/gcc_openbsd_arm64.c
src/runtime/cgo/gcc_openbsd_mips64.c
src/runtime/cgo/gcc_ppc64x.c
src/runtime/cgo/gcc_solaris_amd64.c
src/runtime/cgo/libcgo_unix.h