unix: pass fcntl data as unsafe.Pointer in FcntlF{lock,store} on darwin
FcntlF{lock,store} on Darwin convert their data pointer argument to
uintptr before passing it to the fcntl wrapper. Per the unsafe.Pointer
rules, the conversion is only safe in the call expression itself.
Otherwise, GC could free or move the underlying struct while the syscall
was still using it.
Fix this by adding an unexported fcntlPtr func that takes its arg
argument as unsafe.Pointer and switch FcntlF{lock,store} to call it
instead.
Inspired by CL 836665
Change-Id: I5b662f531a48a02cd7e872c94e3f958d33d6ea7b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/841845
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This repository holds supplemental Go packages for low-level interactions with the operating system.
This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://go.dev/doc/contribute.
The git repository is https://go.googlesource.com/sys.
The main issue tracker for the sys repository is located at https://go.dev/issues. Prefix your issue with “x/sys:” in the subject line, so it is easy to find.