aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2022-07-03 12:26:30 -0400
committerIan Lance Taylor <iant@google.com>2022-07-04 04:09:44 +0000
commit3cf79d96105d890d7097d274804644b2a2093df1 (patch)
tree7a498289cbfd769659be394bbcc50b4a31b378a8
parente822b1e26e20ef1c76672c0b77b0fd8a97a1fe84 (diff)
downloadgo-3cf79d96105d890d7097d274804644b2a2093df1.tar.gz
go-3cf79d96105d890d7097d274804644b2a2093df1.zip
runtime: pass correct string to exits on Plan 9
In CL 405901 the definition of exit in the Plan 9 go runtime was changed like so: - status = append(itoa(tmp[:len(tmp)-1], uint64(e)), 0) + sl := itoa(tmp[:len(tmp)-1], uint64(e)) + // Don't append, rely on the existing data being zero. + status = tmp[:len(sl)+1] However, itoa only puts the converted number "somewhere" in the buffer. Specifically, it builds it from the end of the buffer towards the start, meaning the first byte of the buffer is a 0 byte, and the resulting string that's passed to exits is empty, leading to a falsely successful exit. This change uses the returned value from itoa, rather than the buffer that was passed in, so that we start from the correct location in the string. Fixes #53669 Change-Id: I63f0c7641fc6f55250857dc17a1eeb12ae0c2e10 Reviewed-on: https://go-review.googlesource.com/c/go/+/415680 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
-rw-r--r--src/runtime/os_plan9.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/runtime/os_plan9.go b/src/runtime/os_plan9.go
index 13bc3be4ab..f0e7c6ae70 100644
--- a/src/runtime/os_plan9.go
+++ b/src/runtime/os_plan9.go
@@ -439,7 +439,7 @@ func exit(e int32) {
var tmp [32]byte
sl := itoa(tmp[:len(tmp)-1], uint64(e))
// Don't append, rely on the existing data being zero.
- status = tmp[:len(sl)+1]
+ status = sl[:len(sl)+1]
}
goexitsall(&status[0])
exits(&status[0])