Skip to content

Commit 3cf79d9

Browse files
oridbIan Lance Taylor
authored and
Ian Lance Taylor
committed
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 <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent e822b1e commit 3cf79d9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/runtime/os_plan9.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ func exit(e int32) {
439439
var tmp [32]byte
440440
sl := itoa(tmp[:len(tmp)-1], uint64(e))
441441
// Don't append, rely on the existing data being zero.
442-
status = tmp[:len(sl)+1]
442+
status = sl[:len(sl)+1]
443443
}
444444
goexitsall(&status[0])
445445
exits(&status[0])

0 commit comments

Comments
 (0)