From 283296195b7a06239310871a4321bd649a078924 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Mon, 10 Feb 2025 20:10:22 +0000 Subject: [PATCH] internal/trace: emit a Sync event even if the next generation is broken Since CL 644215 each Sync event now represents the coming generation, with a final Sync event emitted even when there's nothing ahead. This change however failed to emit a Sync event at the end of a completely valid generation when the next generation was invalid, causing the runtime test TestCrashWhileTracing to start failing. Fix this by emitting a final Sync event even when the next generation is broken. We hold onto the error in parsing the next generation and emit it after that final Sync event. (Should these "final" Sync events distinguish themselves in some way?) Fixes #71615. Change-Id: I1f8abee5abaa39e1219e6fa05e9f82f1478db4c9 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/648195 Auto-Submit: Michael Knyszek LUCI-TryBot-Result: Go LUCI Reviewed-by: Cherry Mui --- src/internal/trace/reader.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/internal/trace/reader.go b/src/internal/trace/reader.go index 81710c0125..75b88f7bac 100644 --- a/src/internal/trace/reader.go +++ b/src/internal/trace/reader.go @@ -152,12 +152,10 @@ func (r *Reader) ReadEvent() (e Event, err error) { return syncEvent(nil, r.lastTs, r.syncs), nil } // Read the next generation. - var err error - r.gen, r.spill, err = readGeneration(r.r, r.spill) + r.gen, r.spill, r.spillErr = readGeneration(r.r, r.spill) if r.gen == nil { - return Event{}, err + return syncEvent(nil, r.lastTs, r.syncs), nil } - r.spillErr = err // Reset CPU samples cursor. r.cpuSamples = r.gen.cpuSamples -- 2.51.0