aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Marineau <mike@marineau.org>2017-01-03 00:15:05 -0800
committerIan Lance Taylor <iant@golang.org>2017-01-03 22:35:42 +0000
commit6a1cac27005f5e37c9c4acd0f63121e61b41ae3c (patch)
tree24988cbb76f33855b5c1678487245173bfaad99a
parentd698e614a21cd50055c7c5e7100069d2bcdb9b83 (diff)
downloadgo-6a1cac27005f5e37c9c4acd0f63121e61b41ae3c.tar.gz
go-6a1cac27005f5e37c9c4acd0f63121e61b41ae3c.zip
runtime: check sched_getaffinity return value
Android on ChromeOS uses a restrictive seccomp filter that blocks sched_getaffinity, leading this code to index a slice by -errno. Change-Id: Iec09a4f79dfbc17884e24f39bcfdad305de75b37 Reviewed-on: https://go-review.googlesource.com/34794 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org>
-rw-r--r--src/runtime/os_linux.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go
index 213b951a6b..a6efc0e3d1 100644
--- a/src/runtime/os_linux.go
+++ b/src/runtime/os_linux.go
@@ -91,6 +91,9 @@ func getproccount() int32 {
const maxCPUs = 64 * 1024
var buf [maxCPUs / (sys.PtrSize * 8)]uintptr
r := sched_getaffinity(0, unsafe.Sizeof(buf), &buf[0])
+ if r < 0 {
+ return 1
+ }
n := int32(0)
for _, v := range buf[:r/sys.PtrSize] {
for v != 0 {