mirror of
https://github.com/golang/go
synced 2024-09-23 23:10:13 -06:00
runtime: correct error handling in several FreeBSD syscall wrappers
The FreeBSD syscall convention uses the carry flag to indicate whether an error has occured. The sys_umtx_op, thr_new, and pipe2 syscall wrappers were failing to account for this convention and silently suppressing errors as a result. This commit corrects these wrappers by copying the pattern used by the other fallible syscall wrappers. Note that futexsleep1 must now explicitly ignore the ETIMEDOUT error from sys_umtx_op. Previously ETIMEDOUT was implicitly ignored because sys_umtx_op never returned an error. Fixes #43106. Change-Id: I9c422b87cf4c6d308003bf42c3b419f785578b5d Reviewed-on: https://go-review.googlesource.com/c/go/+/276892 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Austin Clements <austin@google.com> Trust: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
9b6147120a
commit
4d27c4c223
@ -13,10 +13,11 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
_EINTR = 0x4
|
||||
_EFAULT = 0xe
|
||||
_EAGAIN = 0x23
|
||||
_ENOSYS = 0x4e
|
||||
_EINTR = 0x4
|
||||
_EFAULT = 0xe
|
||||
_EAGAIN = 0x23
|
||||
_ENOSYS = 0x4e
|
||||
_ETIMEDOUT = 0x3c
|
||||
|
||||
_O_NONBLOCK = 0x4
|
||||
_O_CLOEXEC = 0x100000
|
||||
|
@ -13,10 +13,11 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
_EINTR = 0x4
|
||||
_EFAULT = 0xe
|
||||
_EAGAIN = 0x23
|
||||
_ENOSYS = 0x4e
|
||||
_EINTR = 0x4
|
||||
_EFAULT = 0xe
|
||||
_EAGAIN = 0x23
|
||||
_ENOSYS = 0x4e
|
||||
_ETIMEDOUT = 0x3c
|
||||
|
||||
_O_NONBLOCK = 0x4
|
||||
_O_CLOEXEC = 0x100000
|
||||
|
@ -13,10 +13,11 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
_EINTR = 0x4
|
||||
_EFAULT = 0xe
|
||||
_EAGAIN = 0x23
|
||||
_ENOSYS = 0x4e
|
||||
_EINTR = 0x4
|
||||
_EFAULT = 0xe
|
||||
_EAGAIN = 0x23
|
||||
_ENOSYS = 0x4e
|
||||
_ETIMEDOUT = 0x3c
|
||||
|
||||
_O_NONBLOCK = 0x4
|
||||
_O_CLOEXEC = 0x100000
|
||||
|
@ -13,10 +13,11 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
_EINTR = 0x4
|
||||
_EFAULT = 0xe
|
||||
_EAGAIN = 0x23
|
||||
_ENOSYS = 0x4e
|
||||
_EINTR = 0x4
|
||||
_EFAULT = 0xe
|
||||
_EAGAIN = 0x23
|
||||
_ENOSYS = 0x4e
|
||||
_ETIMEDOUT = 0x3c
|
||||
|
||||
_O_NONBLOCK = 0x4
|
||||
_O_CLOEXEC = 0x100000
|
||||
|
@ -166,7 +166,7 @@ func futexsleep1(addr *uint32, val uint32, ns int64) {
|
||||
utp = &ut
|
||||
}
|
||||
ret := sys_umtx_op(addr, _UMTX_OP_WAIT_UINT_PRIVATE, val, unsafe.Sizeof(*utp), utp)
|
||||
if ret >= 0 || ret == -_EINTR {
|
||||
if ret >= 0 || ret == -_EINTR || ret == -_ETIMEDOUT {
|
||||
return
|
||||
}
|
||||
print("umtx_wait addr=", addr, " val=", val, " ret=", ret, "\n")
|
||||
@ -208,7 +208,6 @@ func newosproc(mp *m) {
|
||||
|
||||
var oset sigset
|
||||
sigprocmask(_SIG_SETMASK, &sigset_all, &oset)
|
||||
// TODO: Check for error.
|
||||
ret := thr_new(¶m, int32(unsafe.Sizeof(param)))
|
||||
sigprocmask(_SIG_SETMASK, &oset, nil)
|
||||
if ret < 0 {
|
||||
|
@ -13,12 +13,16 @@
|
||||
TEXT runtime·sys_umtx_op(SB),NOSPLIT,$-4
|
||||
MOVL $454, AX
|
||||
INT $0x80
|
||||
JAE 2(PC)
|
||||
NEGL AX
|
||||
MOVL AX, ret+20(FP)
|
||||
RET
|
||||
|
||||
TEXT runtime·thr_new(SB),NOSPLIT,$-4
|
||||
MOVL $455, AX
|
||||
INT $0x80
|
||||
JAE 2(PC)
|
||||
NEGL AX
|
||||
MOVL AX, ret+8(FP)
|
||||
RET
|
||||
|
||||
@ -120,6 +124,8 @@ TEXT runtime·pipe2(SB),NOSPLIT,$12-16
|
||||
MOVL flags+0(FP), BX
|
||||
MOVL BX, 8(SP)
|
||||
INT $0x80
|
||||
JAE 2(PC)
|
||||
NEGL AX
|
||||
MOVL AX, errno+12(FP)
|
||||
RET
|
||||
|
||||
|
@ -18,6 +18,8 @@ TEXT runtime·sys_umtx_op(SB),NOSPLIT,$0
|
||||
MOVQ ut+24(FP), R8
|
||||
MOVL $454, AX
|
||||
SYSCALL
|
||||
JCC 2(PC)
|
||||
NEGQ AX
|
||||
MOVL AX, ret+32(FP)
|
||||
RET
|
||||
|
||||
@ -26,6 +28,8 @@ TEXT runtime·thr_new(SB),NOSPLIT,$0
|
||||
MOVL size+8(FP), SI
|
||||
MOVL $455, AX
|
||||
SYSCALL
|
||||
JCC 2(PC)
|
||||
NEGQ AX
|
||||
MOVL AX, ret+16(FP)
|
||||
RET
|
||||
|
||||
@ -118,6 +122,8 @@ TEXT runtime·pipe2(SB),NOSPLIT,$0-20
|
||||
MOVL flags+0(FP), SI
|
||||
MOVL $542, AX
|
||||
SYSCALL
|
||||
JCC 2(PC)
|
||||
NEGQ AX
|
||||
MOVL AX, errno+16(FP)
|
||||
RET
|
||||
|
||||
|
@ -51,6 +51,7 @@ TEXT runtime·sys_umtx_op(SB),NOSPLIT,$0
|
||||
ADD $20, R13 // arg 5 is passed on stack
|
||||
MOVW $SYS__umtx_op, R7
|
||||
SWI $0
|
||||
RSB.CS $0, R0
|
||||
SUB $20, R13
|
||||
// BCS error
|
||||
MOVW R0, ret+20(FP)
|
||||
@ -61,6 +62,7 @@ TEXT runtime·thr_new(SB),NOSPLIT,$0
|
||||
MOVW size+4(FP), R1
|
||||
MOVW $SYS_thr_new, R7
|
||||
SWI $0
|
||||
RSB.CS $0, R0
|
||||
MOVW R0, ret+8(FP)
|
||||
RET
|
||||
|
||||
@ -144,6 +146,7 @@ TEXT runtime·pipe2(SB),NOSPLIT,$0-16
|
||||
MOVW flags+0(FP), R1
|
||||
MOVW $SYS_pipe2, R7
|
||||
SWI $0
|
||||
RSB.CS $0, R0
|
||||
MOVW R0, errno+12(FP)
|
||||
RET
|
||||
|
||||
|
@ -60,6 +60,9 @@ TEXT runtime·sys_umtx_op(SB),NOSPLIT,$0
|
||||
MOVD ut+24(FP), R4
|
||||
MOVD $SYS__umtx_op, R8
|
||||
SVC
|
||||
BCC ok
|
||||
NEG R0, R0
|
||||
ok:
|
||||
MOVW R0, ret+32(FP)
|
||||
RET
|
||||
|
||||
@ -69,6 +72,9 @@ TEXT runtime·thr_new(SB),NOSPLIT,$0
|
||||
MOVW size+8(FP), R1
|
||||
MOVD $SYS_thr_new, R8
|
||||
SVC
|
||||
BCC ok
|
||||
NEG R0, R0
|
||||
ok:
|
||||
MOVW R0, ret+16(FP)
|
||||
RET
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user