golang/src/runtime/cgo
Michael Pratt 1ffc296717 runtime: always update stack bounds on cgocallback
callbackUpdateSystemStack contains a fast path to exit early without
update if SP is already within the g0.stack bounds.

This is not safe, as a subsequent call may have new stack bounds that
only partially overlap the old stack bounds. In this case it is possible
to see an SP that is in the old stack bounds, but very close to the
bottom of the bounds due to the partial overlap. In that case we're very
likely to "run out" of space on the system stack.

We only need to do this on extra Ms, as normal Ms have precise bounds
defined when we allocated the stack.

TSAN annotations are added to x_cgo_getstackbounds because bounds is a
pointer into the Go stack. The stack can be reused when an old thread
exits and a new thread starts, but TSAN can't see the synchronization
there. This isn't a new case, but we are now calling more often.

Fixes #62440.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Change-Id: I5389050494987b7668d0b317fb92f85e61d798ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/584597
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-16 01:32:45 +00:00
..
abi_amd64.h runtime: unify C->Go ABI transitions 2021-04-15 12:38:13 +00:00
abi_arm64.h runtime: unify C->Go ABI transitions on arm64 2022-03-30 01:28:43 +00:00
abi_loong64.h runtime: save/restore callee-saved registers in loong64's sigtramp 2023-03-29 02:34:18 +00:00
abi_ppc64x.h runtime: cleanup PPC64/linux runtime.sigtramp 2023-04-03 20:17:02 +00:00
asm_386.s runtime/cgo: avoid taking the address of crosscall2 in code 2023-10-12 00:43:51 +00:00
asm_amd64.s runtime/cgo: avoid taking the address of crosscall2 in code 2023-10-12 00:43:51 +00:00
asm_arm.s all: add floating point option for ARM targets 2023-11-20 17:19:36 +00:00
asm_arm64.s runtime/cgo: avoid taking the address of crosscall2 in code 2023-10-12 00:43:51 +00:00
asm_loong64.s runtime/cgo: avoid taking the address of crosscall2 in code 2023-10-12 00:43:51 +00:00
asm_mips64x.s runtime/cgo: avoid taking the address of crosscall2 in code 2023-10-12 00:43:51 +00:00
asm_mipsx.s runtime/cgo: avoid taking the address of crosscall2 in code 2023-10-12 00:43:51 +00:00
asm_ppc64x.s runtime/cgo: avoid taking the address of crosscall2 in code 2023-10-12 00:43:51 +00:00
asm_riscv64.s runtime/cgo: avoid taking the address of crosscall2 in code 2023-10-12 00:43:51 +00:00
asm_s390x.s runtime/cgo: avoid taking the address of crosscall2 in code 2023-10-12 00:43:51 +00:00
asm_wasm.s runtime/cgo: store M for C-created thread in pthread key 2023-05-17 21:53:11 +00:00
callbacks.go runtime/cgo: store M for C-created thread in pthread key 2023-05-17 21:53:11 +00:00
callbacks_aix.go all: separate doc comment from //go: directives 2022-04-05 17:54:15 +00:00
callbacks_traceback.go all: go fix -fix=buildtag std cmd (except for bootstrap deps, vendor) 2021-10-28 18:17:57 +00:00
cgo.go cmd/cgo: add -fno-stack-protector to CFLAGS (again) 2023-02-10 14:29:46 +00:00
dragonfly.go all: go fix -fix=buildtag std cmd (except for bootstrap deps, vendor) 2021-10-28 18:17:57 +00:00
freebsd.go all: go fix -fix=buildtag std cmd (except for bootstrap deps, vendor) 2021-10-28 18:17:57 +00:00
gcc_386.S runtime/cgo: rename crosscall_386 to crosscall1 and standardise API 2023-08-12 03:56:58 +00:00
gcc_aix_ppc64.S runtime/cgo: use //go:build lines in C and assembly files 2023-01-24 22:38:02 +00:00
gcc_aix_ppc64.c runtime/cgo: use //go:build lines in C and assembly files 2023-01-24 22:38:02 +00:00
gcc_amd64.S runtime/cgo: rename crosscall_amd64 to crosscall1 2023-08-12 03:56:28 +00:00
gcc_android.c runtime: fix dead link in gcc_androd.c file 2020-05-09 23:17:17 +00:00
gcc_arm.S runtime/cgo: rename crosscall_arm1 to crosscall1 2023-08-15 03:39:42 +00:00
gcc_arm64.S runtime/cgo: add .file directive to GNU assembly files 2022-12-05 16:41:48 +00:00
gcc_context.c runtime/cgo: use //go:build lines in C and assembly files 2023-01-24 22:38:02 +00:00
gcc_darwin_amd64.c runtime/cgo: rename crosscall_amd64 to crosscall1 2023-08-12 03:56:28 +00:00
gcc_darwin_arm64.c runtime/cgo: use frame address to set g0 stack bound 2023-08-09 03:13:11 +00:00
gcc_dragonfly_amd64.c runtime/cgo: use fatalf on dragonfly, freebsd, netbsd and openbsd 2023-08-15 03:39:26 +00:00
gcc_fatalf.c runtime/cgo: use fatalf on solaris 2023-08-15 14:57:16 +00:00
gcc_freebsd.c runtime/cgo: consolidate freebsd cgo code 2023-08-15 03:40:00 +00:00
gcc_freebsd_amd64.c runtime/cgo: get getstackbound for set_stacklo 2023-08-22 22:06:46 +00:00
gcc_freebsd_sigaction.c runtime/cgo: use //go:build lines in C and assembly files 2023-01-24 22:38:02 +00:00
gcc_libinit.c runtime/cgo: ignore unknown warning options 2024-02-29 01:07:18 +00:00
gcc_libinit_windows.c runtime/cgo: store M for C-created thread in pthread key 2023-05-17 21:53:11 +00:00
gcc_linux.c runtime/cgo: consolidate linux cgo code 2023-08-15 03:55:36 +00:00
gcc_linux_amd64.c runtime/cgo: get getstackbound for set_stacklo 2023-08-22 22:06:46 +00:00
gcc_linux_arm64.c runtime/cgo: get getstackbound for set_stacklo 2023-08-22 22:06:46 +00:00
gcc_linux_ppc64x.S runtime/cgo: preserve VRs across crosscall_ppc64 on linux 2023-05-04 18:03:04 +00:00
gcc_linux_s390x.c runtime/cgo: use frame address to set g0 stack bound 2023-08-09 03:13:11 +00:00
gcc_loong64.S runtime/cgo: fix typo in gcc_loong64.S 2022-12-05 18:57:04 +00:00
gcc_mips64x.S runtime/cgo: use //go:build lines in C and assembly files 2023-01-24 22:38:02 +00:00
gcc_mipsx.S runtime/cgo: use //go:build lines in C and assembly files 2023-01-24 22:38:02 +00:00
gcc_mmap.c runtime, cmd/go: enable memory sanitizer on linux/loong64 2023-08-25 20:58:13 +00:00
gcc_netbsd.c runtime/cgo: consolidate netbsd cgo code 2023-08-15 03:55:51 +00:00
gcc_openbsd.c runtime/cgo: consolidate openbsd cgo code 2023-08-15 03:56:03 +00:00
gcc_ppc64x.c runtime/cgo: use frame address to set g0 stack bound 2023-08-09 03:13:11 +00:00
gcc_riscv64.S runtime/cgo: add .file directive to GNU assembly files 2022-12-05 16:41:48 +00:00
gcc_s390x.S runtime/cgo: add .file directive to GNU assembly files 2022-12-05 16:41:48 +00:00
gcc_setenv.c runtime/cgo: use //go:build lines in C and assembly files 2023-01-24 22:38:02 +00:00
gcc_sigaction.c runtime/cgo: use //go:build lines in C and assembly files 2023-01-24 22:38:02 +00:00
gcc_signal2_ios_arm64.c runtime/cgo: use //go:build lines in C and assembly files 2023-01-24 22:38:02 +00:00
gcc_signal_ios_arm64.c runtime/cgo: fix clang mach_port_t cast warning 2024-03-21 21:04:22 +00:00
gcc_signal_ios_nolldb.c runtime/cgo: use //go:build lines in C and assembly files 2023-01-24 22:38:02 +00:00
gcc_solaris_amd64.c runtime/cgo: use fatalf on solaris 2023-08-15 14:57:16 +00:00
gcc_stack_darwin.c runtime: always update stack bounds on cgocallback 2024-05-16 01:32:45 +00:00
gcc_stack_unix.c runtime: always update stack bounds on cgocallback 2024-05-16 01:32:45 +00:00
gcc_stack_windows.c runtime/cgo: store M for C-created thread in pthread key 2023-05-17 21:53:11 +00:00
gcc_traceback.c runtime/cgo: add tsan sync for traceback function 2023-03-08 20:11:59 +00:00
gcc_util.c
gcc_windows_386.c runtime/cgo: rename crosscall_386 to crosscall1 and standardise API 2023-08-12 03:56:58 +00:00
gcc_windows_amd64.c runtime/cgo: rename crosscall_amd64 to crosscall1 2023-08-12 03:56:28 +00:00
gcc_windows_arm64.c runtime/cgo: merge bodies of cgo_sys_thread_start on windows 2022-06-09 18:17:39 +00:00
handle.go runtime: add available godoc link 2023-11-08 16:59:11 +00:00
handle_test.go all: gofmt -w -r 'interface{} -> any' src 2021-12-13 18:45:54 +00:00
iscgo.go
libcgo.h runtime/cgo: mark fatalf as noreturn 2024-02-13 20:50:04 +00:00
libcgo_unix.h runtime/cgo: get getstackbound for set_stacklo 2023-08-22 22:06:46 +00:00
libcgo_windows.h runtime/cgo: merge bodies of cgo_sys_thread_start on windows 2022-06-09 18:17:39 +00:00
linux.go all: go fix -fix=buildtag std cmd (except for bootstrap deps, vendor) 2021-10-28 18:17:57 +00:00
linux_syscall.c runtime/cgo: use //go:build lines in C and assembly files 2023-01-24 22:38:02 +00:00
mmap.go runtime, cmd/go: enable memory sanitizer on linux/loong64 2023-08-25 20:58:13 +00:00
netbsd.go all: go fix -fix=buildtag std cmd (except for bootstrap deps, vendor) 2021-10-28 18:17:57 +00:00
openbsd.go all: separate doc comment from //go: directives 2022-04-05 17:54:15 +00:00
setenv.go all: use new "unix" build tag where appropriate 2022-03-29 16:24:51 +00:00
sigaction.go all: go fix -fix=buildtag std cmd (except for bootstrap deps, vendor) 2021-10-28 18:17:57 +00:00
signal_ios_arm64.go runtime/cgo: only build xx_cgo_panicmem on iOS 2020-10-06 22:54:58 +00:00
signal_ios_arm64.s runtime/cgo: only build xx_cgo_panicmem on iOS 2020-10-06 22:54:58 +00:00