• Austin Clements's avatar
    runtime: protect sudog.elem with hchan.lock · db72b41b
    Austin Clements authored
    Currently sudog.elem is never accessed concurrently, so in several
    cases we drop the channel lock just before reading/writing the
    sent/received value from/to sudog.elem. However, concurrent stack
    shrinking is going to have to adjust sudog.elem to point to the new
    stack, which means it needs a way to synchronize with accesses to
    sudog.elem. Hence, add sudog.elem to the fields protected by
    hchan.lock and scoot the unlocks down past the uses of sudog.elem.
    
    While we're here, better document the channel synchronization rules.
    
    For #12967.
    
    Change-Id: I3ad0ca71f0a74b0716c261aef21b2f7f13f74917
    Reviewed-on: https://go-review.googlesource.com/20040Reviewed-by: default avatarKeith Randall <khr@golang.org>
    Run-TryBot: Austin Clements <austin@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    db72b41b
runtime2.go 24.1 KB