diff options
| author | Ian Lance Taylor <iant@golang.org> | 2023-07-26 11:58:44 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-07-27 22:20:25 +0000 |
| commit | 737a5b0eaaff9098a41c04bcee5585678766bfae (patch) | |
| tree | c489667ca6343bd156894c1acc0452d5777fca8d /src | |
| parent | 9b0361e549949a208aa6bbcdff25506a3f97d7a9 (diff) | |
| download | go-737a5b0eaaff9098a41c04bcee5585678766bfae.tar.xz | |
runtime: call miniterrno on m0 on AIX and Solaris
AIX and Solaris call into libc for syscalls, and expect M.mOS.perrno
to point to the thread-local errno value for the current M.
We initialize that field in miniterrno called from mstart.
However, this means that any libc calls before mstart will not
return the correct errno value.
This caused trouble in checkfds, which runs very early, before mstart.
We worked around that in 513215. This CL reverts 513215 in favor
of a better workaround: call miniterrno for m0 earlier (we will
still wind up calling miniterrno again from mstart, which does
no harm).
This is a better workaround because it means that if we add future
syscalls before mstart, they will behave as expected.
Fixes #61584
Change-Id: Ib6a0d3c53d2c8214cc339a5019f9d4f71a746f0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/513535
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/runtime/fds_unix.go | 9 | ||||
| -rw-r--r-- | src/runtime/os3_solaris.go | 4 | ||||
| -rw-r--r-- | src/runtime/os_aix.go | 4 |
3 files changed, 8 insertions, 9 deletions
diff --git a/src/runtime/fds_unix.go b/src/runtime/fds_unix.go index f39e6a49e9..7182ef0789 100644 --- a/src/runtime/fds_unix.go +++ b/src/runtime/fds_unix.go @@ -29,15 +29,6 @@ func checkfds() { continue } - // On AIX and Solaris we can't get the right errno - // value this early in program startup, - // because we haven't yet called minit - // which sets m.mOS.perrno. - // Just assume that the error is EBADF. - if GOOS == "aix" || GOOS == "solaris" { - errno = EBADF - } - if errno != EBADF { print("runtime: unexpected error while checking standard file descriptor ", i, ", errno=", errno, "\n") throw("cannot open standard fds") diff --git a/src/runtime/os3_solaris.go b/src/runtime/os3_solaris.go index 046d173c24..83acc648bb 100644 --- a/src/runtime/os3_solaris.go +++ b/src/runtime/os3_solaris.go @@ -133,6 +133,10 @@ func getPageSize() uintptr { } func osinit() { + // Call miniterrno so that we can safely make system calls + // before calling minit on m0. + asmcgocall(unsafe.Pointer(abi.FuncPCABI0(miniterrno)), unsafe.Pointer(&libc____errno)) + ncpu = getncpu() if physPageSize == 0 { physPageSize = getPageSize() diff --git a/src/runtime/os_aix.go b/src/runtime/os_aix.go index 0583e9afdb..ce2d719d0b 100644 --- a/src/runtime/os_aix.go +++ b/src/runtime/os_aix.go @@ -93,6 +93,10 @@ func semawakeup(mp *m) { } func osinit() { + // Call miniterrno so that we can safely make system calls + // before calling minit on m0. + miniterrno() + ncpu = int32(sysconf(__SC_NPROCESSORS_ONLN)) physPageSize = sysconf(__SC_PAGE_SIZE) } |
