• Rui Ueyama's avatar
    sync: fix spurious wakeup from WaitGroup.Wait · e9347c78
    Rui Ueyama authored
    There is a race condition that causes spurious wakeup from Wait
    in the following case:
    
     G1: decrement wg.counter, observe the counter is now 0
         (should unblock goroutines queued *at this moment*)
     G2: increment wg.counter
     G2: call Wait() to add itself to the wait queue
     G1: acquire wg.m, unblock all waiting goroutines
    
    In the last step G2 is spuriously woken up by G1.
    Fixes #7734.
    
    LGTM=rsc, dvyukov
    R=dvyukov, 0xjnml, rsc
    CC=golang-codereviews
    https://golang.org/cl/85580043
    e9347c78
Name
Last commit
Last update
..
atomic Loading commit data...
cond.go Loading commit data...
cond_test.go Loading commit data...
example_test.go Loading commit data...
export_test.go Loading commit data...
mutex.go Loading commit data...
mutex_test.go Loading commit data...
once.go Loading commit data...
once_test.go Loading commit data...
pool.go Loading commit data...
pool_test.go Loading commit data...
race.go Loading commit data...
race0.go Loading commit data...
runtime.go Loading commit data...
runtime_sema_test.go Loading commit data...
rwmutex.go Loading commit data...
rwmutex_test.go Loading commit data...
waitgroup.go Loading commit data...
waitgroup_test.go Loading commit data...