Skip to content

Commit 62c7e57

Browse files
committed
sumdb: handle panic from c.ReadRemote during ReadTiles
The go command tests use a network stack that sometimes panics during read. This code was assuming a network stack that returns errors instead. If a tile-reading goroutine panicked, ReadTiles considered it done with data, err = nil, nil, and then there was a race between ReadTiles failing with an error about a suspiciously short tile and the panicking goroutine getting to run and bring down the entire program. Remove the race by converting the panic into an error during ReadTiles. For a test in golang/go#57001. Change-Id: I9b18a244238e67c27a15b93f8397bf3ab44b06e6 Reviewed-on: https://go-review.googlesource.com/c/mod/+/501035 Run-TryBot: Russ Cox <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
1 parent 2a1c06a commit 62c7e57

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

sumdb/client.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,11 @@ func (r *tileReader) ReadTiles(tiles []tlog.Tile) ([][]byte, error) {
553553
wg.Add(1)
554554
go func(i int, tile tlog.Tile) {
555555
defer wg.Done()
556+
defer func() {
557+
if e := recover(); e != nil {
558+
errs[i] = fmt.Errorf("panic: %v", e)
559+
}
560+
}()
556561
data[i], errs[i] = r.c.readTile(tile)
557562
}(i, tile)
558563
}

0 commit comments

Comments
 (0)