Skip to content

Commit

Permalink
cmd/trace: handle invalid goid para in /trace
Browse files Browse the repository at this point in the history
Change-Id: I1cb7c8b70a5ae16386f6abb577c23d821f7ff7f0
Reviewed-on: https://go-review.googlesource.com/112197
Reviewed-by: Peter Weinberger <[email protected]>
Run-TryBot: Hyang-Ah Hana Kim <[email protected]>
  • Loading branch information
hyangah committed May 8, 2018
1 parent 9eface7 commit 43b18f4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/cmd/trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,15 @@ func httpJsonTrace(w http.ResponseWriter, r *http.Request) {
// If goid argument is present, we are rendering a trace for this particular goroutine.
goid, err := strconv.ParseUint(goids, 10, 64)
if err != nil {
log.Printf("failed to parse goid parameter '%v': %v", goids, err)
log.Printf("failed to parse goid parameter %q: %v", goids, err)
return
}
analyzeGoroutines(res.Events)
g := gs[goid]
g, ok := gs[goid]
if !ok {
log.Printf("failed to find goroutine %d", goid)
return
}
params.mode = modeGoroutineOriented
params.startTime = g.StartTime
if g.EndTime != 0 {
Expand Down Expand Up @@ -249,12 +253,12 @@ func httpJsonTrace(w http.ResponseWriter, r *http.Request) {
// If start/end arguments are present, we are rendering a range of the trace.
start, err = strconv.ParseInt(startStr, 10, 64)
if err != nil {
log.Printf("failed to parse start parameter '%v': %v", startStr, err)
log.Printf("failed to parse start parameter %q: %v", startStr, err)
return
}
end, err = strconv.ParseInt(endStr, 10, 64)
if err != nil {
log.Printf("failed to parse end parameter '%v': %v", endStr, err)
log.Printf("failed to parse end parameter %q: %v", endStr, err)
return
}
}
Expand Down

0 comments on commit 43b18f4

Please sign in to comment.