Skip to content

Commit

Permalink
runtime: guard against array out of bounds in GoroutineProfile
Browse files Browse the repository at this point in the history
The previous CL is the real fix. This one is just insurance.

Fixes golang#14046 again.

Change-Id: I553349504bb1789e4b66c888dbe4034568918ad6
Reviewed-on: https://go-review.googlesource.com/18977
Reviewed-by: Austin Clements <[email protected]>
  • Loading branch information
rsc committed Jan 27, 2016
1 parent 313fd1c commit d9fdbf4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/runtime/mprof.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:]
}
Expand Down

0 comments on commit d9fdbf4

Please sign in to comment.