]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: call _exit, not exit, on AIX and Solaris
authorIan Lance Taylor <iant@golang.org>
Sat, 22 Apr 2023 01:48:38 +0000 (18:48 -0700)
committerGopher Robot <gobot@golang.org>
Mon, 24 Apr 2023 05:12:17 +0000 (05:12 +0000)
This is the AIX and Solaris equivalent of CL 269378.

On AIX and Solaris, where we use libc for syscalls, when the runtime exits,
it calls the libc exit function, which may call back into user code,
such as 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 AIX and Solaris to achieve the same
behavior.

Test is TestDestructorCallback.

For #59711

Change-Id: I666f75538d3e3d8cf3b697b4c32f3ecde8332890
Reviewed-on: https://go-review.googlesource.com/c/go/+/487635
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

src/runtime/os2_aix.go
src/runtime/os3_solaris.go

index 2efc56554cddcceddbb418e91c5fc7a9d7df9289..e55dd9833e097f5263995eb44ddfdd544ff958d7 100644 (file)
@@ -31,7 +31,7 @@ var (
 //go:cgo_import_dynamic libc__Errno _Errno "libc.a/shr_64.o"
 //go:cgo_import_dynamic libc_clock_gettime clock_gettime "libc.a/shr_64.o"
 //go:cgo_import_dynamic libc_close close "libc.a/shr_64.o"
-//go:cgo_import_dynamic libc_exit exit "libc.a/shr_64.o"
+//go:cgo_import_dynamic libc_exit _exit "libc.a/shr_64.o"
 //go:cgo_import_dynamic libc_getpid getpid "libc.a/shr_64.o"
 //go:cgo_import_dynamic libc_getsystemcfg getsystemcfg "libc.a/shr_64.o"
 //go:cgo_import_dynamic libc_kill kill "libc.a/shr_64.o"
index 2a8677b48f64a7fa2601bdd9b7434e02a5675114..42fe3790e3a431d2cb9696ea5eb610a75e34c7db 100644 (file)
@@ -17,7 +17,7 @@ import (
 
 //go:cgo_import_dynamic libc____errno ___errno "libc.so"
 //go:cgo_import_dynamic libc_clock_gettime clock_gettime "libc.so"
-//go:cgo_import_dynamic libc_exit exit "libc.so"
+//go:cgo_import_dynamic libc_exit _exit "libc.so"
 //go:cgo_import_dynamic libc_getcontext getcontext "libc.so"
 //go:cgo_import_dynamic libc_kill kill "libc.so"
 //go:cgo_import_dynamic libc_madvise madvise "libc.so"