Commit cd285f1c authored by Dmitry Vyukov's avatar Dmitry Vyukov

runtime: fix global buffer reset in StopTrace

We reset global buffer only if its pos != 0.
We ought to do it always, but queue it only if pos != 0.
This is a latent bug. Currently it does not fire because
whenever we create a global buffer, we increment pos.

Change-Id: I01e28ae88ce9a5412497c524391b8b7cb443ffd9
Reviewed-on: https://go-review.googlesource.com/25574
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarAustin Clements <austin@google.com>
parent 59877bfa
......@@ -262,11 +262,13 @@ func StopTrace() {
p.tracebuf = 0
}
}
if trace.buf != 0 && trace.buf.ptr().pos != 0 {
if trace.buf != 0 {
buf := trace.buf
trace.buf = 0
if buf.ptr().pos != 0 {
traceFullQueue(buf)
}
}
for {
trace.ticksEnd = cputicks()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment