runtime: several FreeBSD syscall wrappers seem to mishandle errors #43106
Labels
FrozenDueToAge
help wanted
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
I'm in the process of porting gccgo to FreeBSD and noticed something sketchy about some of the FreeBSD-specific syscall wrappers in the runtime package. Consider sys_umtx_op for example:
go/src/runtime/sys_freebsd_amd64.s
Lines 13 to 22 in 89f465c
The caller of this function expects negative values to be errors and positive values to be successes:
go/src/runtime/os_freebsd.go
Lines 168 to 171 in 904e113
But sys_umtx_op returns the result of the syscall (the
AX
register) directly, and according to the FreeBSD calling convention, the carry flag indicates whetherAX
contains an error code or successful return code, not the sign of the result. Most of the other syscalls in the package seem to get this right (anything that contains aJCC
instruction afterSYSCALL
, roughly speaking, looks right to me), but a few others seem broken in the same way, likethr_new
andpipe2
.#10052 seems to be some prior art on this subject. As a result a number of these syscall wrappers were fixed to inspect the carry flag, but not all of them.
Clearly in practice this doesn't seem to matter much, but probably worth fixing nonetheless.
The text was updated successfully, but these errors were encountered: