Closed
Description
by Matthew.Horsnell:
It may be worth adding an explicit comment in the documentation for sync.WaitGroup that the call to Add should be done before launching the go routine containing the call to Done. You may never notice this race condition until shipping code, but the call to Add after launching the go routine may not execute until the go routine completes, which will generate a runtime panic as the call to Done inside the routine makes the waitgroup negative. What steps will reproduce the problem? 1. Code like http://play.golang.org/p/y_6dKky3qX 2. May occasionally panic due to the waitgroup becoming negative