diff options
author | Russ Cox <rsc@golang.org> | 2016-01-26 23:00:41 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2016-01-27 04:56:32 +0000 |
commit | d9fdbf48207e24c1d0d771250f2cc811ef97adff (patch) | |
tree | 3a5f4c3d8628b04e16a55170056aa74f6e8d3b96 | |
parent | 313fd1cb1343e46b563b6b8acfef7e58604b5b8f (diff) | |
download | go-d9fdbf48207e24c1d0d771250f2cc811ef97adff.tar.gz go-d9fdbf48207e24c1d0d771250f2cc811ef97adff.zip |
runtime: guard against array out of bounds in GoroutineProfile
The previous CL is the real fix. This one is just insurance.
Fixes #14046 again.
Change-Id: I553349504bb1789e4b66c888dbe4034568918ad6
Reviewed-on: https://go-review.googlesource.com/18977
Reviewed-by: Austin Clements <austin@google.com>
-rw-r--r-- | src/runtime/mprof.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/runtime/mprof.go b/src/runtime/mprof.go index e45bc7a770..fc73bbfbe1 100644 --- a/src/runtime/mprof.go +++ b/src/runtime/mprof.go @@ -554,6 +554,11 @@ func GoroutineProfile(p []StackRecord) (n int, ok bool) { // Save other goroutines. for _, gp1 := range allgs { if isOK(gp1) { + if len(r) == 0 { + // Should be impossible, but better to return a + // truncated profile than to crash the entire process. + break + } saveg(^uintptr(0), ^uintptr(0), gp1, &r[0]) r = r[1:] } |