syscall: handle undefined r2 value on linux-ppc64x

This change fixes two failng tests on linux-ppc64x:

- TestAllThreadsSyscall() exposed a real bug in the ppc64x support:
  - It turns out that the r2 syscall return value is not defined
    on all architectures. Notably linux-ppc64x so address that by
    introducing a private architectural constant in the syscall
    package, archHonorsR2: true if r2 has a determanistic value.

- TestSetuidEtc() was sensitive to /proc/<PID>/status content:
  - The amount of padding space has changed with kernel vintage.
  - Stress testing revealed a race with /proc files disappearing.

Fixes #42178

Change-Id: Ie6fc0b8f2f94a409ac0e5756e73bfce113274709
Reviewed-on: https://go-review.googlesource.com/c/go/+/266202
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Andrew G. Morgan 2020-10-28 13:35:57 -07:00 committed by Ian Lance Taylor
parent 4fb4291388
commit 3a819e8998
11 changed files with 91 additions and 31 deletions

View file

@ -6,6 +6,12 @@ package syscall
import "unsafe"
// archHonorsR2 captures the fact that r2 is honored by the
// runtime.GOARCH. Syscall conventions are generally r1, r2, err :=
// syscall(trap, ...). Not all architectures define r2 in their
// ABI. See "man syscall".
const archHonorsR2 = true
const _SYS_setgroups = SYS_SETGROUPS32
func setTimespec(sec, nsec int64) Timespec {