Skip to content

Commit 0915a19

Browse files
sync: deflake TestWaitGroupMisuse3
If one of the helper goroutine panics, the main goroutine call to Wait may hang forever waiting for something to call Done. Put that call in a goroutine like the others. Fixes #35774 Change-Id: I8d2b58d8f473644a49a95338f70111d4e6ed4e12 Reviewed-on: https://go-review.googlesource.com/c/go/+/210218 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
1 parent 6ef7794 commit 0915a19

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/sync/waitgroup_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func TestWaitGroupMisuse3(t *testing.T) {
147147
}
148148
}()
149149
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4))
150-
done := make(chan interface{}, 2)
150+
done := make(chan interface{}, 3)
151151
// The detection is opportunistically, so we want it to panic
152152
// at least in one run out of a million.
153153
for i := 0; i < 1e6; i++ {
@@ -171,8 +171,13 @@ func TestWaitGroupMisuse3(t *testing.T) {
171171
}()
172172
wg.Wait()
173173
}()
174-
wg.Wait()
175-
for j := 0; j < 2; j++ {
174+
go func() {
175+
defer func() {
176+
done <- recover()
177+
}()
178+
wg.Wait()
179+
}()
180+
for j := 0; j < 3; j++ {
176181
if err := <-done; err != nil {
177182
panic(err)
178183
}

0 commit comments

Comments
 (0)