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

For a test in golang/go#57001.

Change-Id: I9b18a244238e67c27a15b93f8397bf3ab44b06e6
Run-TryBot: Russ Cox <>
TryBot-Result: Gopher Robot <>
Reviewed-by: Michael Matloob <>
diff --git a/sumdb/client.go b/sumdb/client.go
index 965a7e2..1c1b029 100644
--- a/sumdb/client.go
+++ b/sumdb/client.go
@@ -553,6 +553,11 @@
 		go func(i int, tile tlog.Tile) {
 			defer wg.Done()
+			defer func() {
+				if e := recover(); e != nil {
+					errs[i] = fmt.Errorf("panic: %v", e)
+				}
+			}()
 			data[i], errs[i] = r.c.readTile(tile)
 		}(i, tile)