From 8438a5779b76620237d608282a99d17467b91f4c Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Wed, 11 Nov 2020 21:27:56 -0500 Subject: [PATCH] runtime: use _exit on darwin On darwin, where we use libc for syscalls, when the runtime exits, it calls libc exit function, which may call back into user code, e.g. invoking functions registered with atexit. In particular, it may call back into Go. But at this point, the Go runtime is already exiting, so this wouldn't work. On non-libc platforms we use exit syscall directly, which doesn't invoke any callbacks. Use _exit on darwin to achieve the same behavior. No test for now, as it doesn't pass on all platforms (see trybot run of PS2). May fix #42465. May fix #43294. Change-Id: Ia1ada22b5da8cb64fdd598d0541eb90e195367eb Reviewed-on: https://go-review.googlesource.com/c/go/+/269378 Trust: Cherry Zhang Run-TryBot: Cherry Zhang TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/runtime/sys_darwin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/sys_darwin.go b/src/runtime/sys_darwin.go index c89ce78012..55845bf2e5 100644 --- a/src/runtime/sys_darwin.go +++ b/src/runtime/sys_darwin.go @@ -467,7 +467,7 @@ func setNonblock(fd int32) { //go:cgo_import_dynamic libc_pthread_create pthread_create "/usr/lib/libSystem.B.dylib" //go:cgo_import_dynamic libc_pthread_self pthread_self "/usr/lib/libSystem.B.dylib" //go:cgo_import_dynamic libc_pthread_kill pthread_kill "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic libc_exit exit "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic libc_exit _exit "/usr/lib/libSystem.B.dylib" //go:cgo_import_dynamic libc_raise raise "/usr/lib/libSystem.B.dylib" //go:cgo_import_dynamic libc_open open "/usr/lib/libSystem.B.dylib" -- 2.50.0