]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: use _exit on darwin
authorCherry Zhang <cherryyz@google.com>
Thu, 12 Nov 2020 02:27:56 +0000 (21:27 -0500)
committerCherry Zhang <cherryyz@google.com>
Mon, 21 Dec 2020 19:16:38 +0000 (19:16 +0000)
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 <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/sys_darwin.go

index c89ce780124cbeca77f57bad28e735e03731a559..55845bf2e51dc9c64e47363bbf96d7d6fc7fd236 100644 (file)
@@ -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"