diff options
| author | Michael Pratt <mpratt@google.com> | 2024-02-02 13:00:02 -0500 |
|---|---|---|
| committer | Michael Pratt <mpratt@google.com> | 2024-02-02 18:35:18 +0000 |
| commit | 3d20a327a1f91ae912865aa13bc07cda9930fefc (patch) | |
| tree | 8c3d651785b80ed643ef03d07ecb1e2536a0865e /src/runtime | |
| parent | 6b0309ceb61e297907d127a46a8faffbc8429f06 (diff) | |
| download | go-3d20a327a1f91ae912865aa13bc07cda9930fefc.tar.xz | |
runtime: initialize crashFD to -1
crashFD defaults to the zero value of (surprise!) zero. Zero is a valid
FD, so on the first call to SetCrashOutput we actually close FD 0 since
it is a "valid" FD.
Initialize crashFD to -1, the sentinel for "no FD".
Change-Id: I3b108c60603f2b83b867cbe079f035c159b6a6ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/560776
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/proc.go | 1 | ||||
| -rw-r--r-- | src/runtime/runtime.go | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go index a7a3fb62cb..538ed0a282 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -775,6 +775,7 @@ func schedinit() { } sched.maxmcount = 10000 + crashFD.Store(^uintptr(0)) // The world starts stopped. worldStopped() diff --git a/src/runtime/runtime.go b/src/runtime/runtime.go index 4dfb2f840a..c7a511b2a4 100644 --- a/src/runtime/runtime.go +++ b/src/runtime/runtime.go @@ -244,6 +244,8 @@ func writeErrData(data *byte, n int32) { // set by debug.SetCrashOutput (see #42888). If it is a valid fd (not // all ones), writeErr and related functions write to it in addition // to standard error. +// +// Initialized to -1 in schedinit. var crashFD atomic.Uintptr //go:linkname setCrashFD |
