runtime: handle nil pointer in sysFreeOS on sbrk platforms On sbrk platforms (Plan 9 and Wasm), sysReserveOS returns nil when it can't reserve memory at the requested hint address. When the caller passes that nil result to sysUnreserve, sysFreeOS reaches memFree(nil), which clears the region with memclrNoHeapPointers, writing to address 0. On Plan 9, this faults the program with a "sys: trap: fault write" note. It is reproducible on plan9/amd64 with TestArenaCollision, which exhausts the arena hints and unreserves the failed reservations. On mmap-based platforms, sysUnreserve(nil) is a harmless munmap(nil). This change makes sysFreeOS return early for a nil pointer, so freeing or unreserving nil is a no-op on sbrk platforms too. Change-Id: I2e3057a5bb34254d600d05b5fa128c77960d4e9a Reviewed-on: https://go-review.googlesource.com/c/go/+/793400 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Richard Miller <millerresearch@gmail.com>
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 4.0 Attribution license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Official binary distributions are available at https://go.dev/dl/.
After downloading a binary release, visit https://go.dev/doc/install for installation instructions.
If a binary distribution is not available for your combination of operating system and architecture, visit https://go.dev/doc/install/source for source installation instructions.
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines at https://go.dev/doc/contribute.
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://go.dev/wiki/Questions for a list of places to ask questions about the Go language.