Skip to content

Commit 77f911e

Browse files
mknyszekgopherbot
authored andcommitted
internal/trace: emit final sync event for generation in Go 1.26+
CL 693398 returned the error from reading a generation immediately, but this is wrong -- a Sync event must be emitted to indicate the end of the trace before reporting the error. This caused TestCrashWhileTracing to fail because that test has a high likelihood of producing a truncated trace, and it expects at least 2 Sync events. The truncated trace error would be reported before the second Sync event, which is incorrect. Fixes golang#75045. Change-Id: Ia71592c4ec56a544afc85cdb7b575e143f80e048 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/696436 Reviewed-by: Carlos Amedee <[email protected]> Auto-Submit: Michael Knyszek <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 786be1d commit 77f911e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/internal/trace/reader.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type Reader struct {
3131
cpuSamples []cpuSample
3232
order ordering
3333
syncs int
34+
readGenErr error
3435
done bool
3536

3637
// Spill state.
@@ -153,9 +154,18 @@ func (r *Reader) ReadEvent() (e Event, err error) {
153154
if r.version < version.Go126 {
154155
return r.nextGenWithSpill()
155156
}
157+
if r.readGenErr != nil {
158+
return Event{}, r.readGenErr
159+
}
156160
gen, err := readGeneration(r.r, r.version)
157161
if err != nil {
158-
return Event{}, err
162+
// Before returning an error, emit the sync event
163+
// for the current generation and queue up the error
164+
// for the next call.
165+
r.readGenErr = err
166+
r.gen = nil
167+
r.syncs++
168+
return syncEvent(nil, r.lastTs, r.syncs), nil
159169
}
160170
return r.installGen(gen)
161171
}

0 commit comments

Comments
 (0)