From 6bbbc5dc70e9e5698818d5c47b6536e72619884b Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 21 Apr 2023 18:48:38 -0700 Subject: [PATCH] runtime: call _exit, not exit, on AIX and Solaris 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 Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: Cherry Mui Auto-Submit: Ian Lance Taylor --- src/runtime/os2_aix.go | 2 +- src/runtime/os3_solaris.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/os2_aix.go b/src/runtime/os2_aix.go index 2efc56554cd..e55dd9833e0 100644 --- a/src/runtime/os2_aix.go +++ b/src/runtime/os2_aix.go @@ -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" diff --git a/src/runtime/os3_solaris.go b/src/runtime/os3_solaris.go index 2a8677b48f6..42fe3790e3a 100644 --- a/src/runtime/os3_solaris.go +++ b/src/runtime/os3_solaris.go @@ -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"