Skip to content

Commit 5d81a7e

Browse files
committed
3
1 parent b8cd222 commit 5d81a7e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/sync/waitgroup.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,16 @@ func (wg *WaitGroup) Go(f func()) {
238238
go func() {
239239
defer func() {
240240
if x := recover(); x != nil {
241-
// Don't call Done as it may cause Wait to unblock,
242-
// so that the main goroutine races with the runtime.fatal
243-
// resulting from unhandled panic.
241+
// f panicked, which will be fatal because
242+
// this is a new goroutine.
243+
//
244+
// Calling Done will unblock Wait in the main goroutine,
245+
// allowing it to race with the fatal panic and
246+
// possibly even exit the process (os.Exit(0))
247+
// before the panic completes.
248+
//
249+
// This is almost certainly undesirable,
250+
// so instead avoid calling Done and simply panic.
244251
panic(x)
245252
}
246253

0 commit comments

Comments
 (0)