• Austin Clements's avatar
    runtime: don't spin in checkPut if non-preemptible · 8e639611
    Austin Clements authored
    Currently it's possible for the runtime to deadlock if checkPut is
    called in a non-preemptible context. In this case, checkPut may spin,
    so it won't leave the non-preemptible context, but the thread running
    gcMarkDone needs to preempt all of the goroutines before it can
    release the checkPut spin loops.
    
    Fix this by returning from checkPut if it's called under any of the
    conditions that would prevent gcMarkDone from preempting it. In this
    case, it leaves a note behind that this happened; if the runtime does
    later detect left-over work it can at least indicate that it was
    unable to catch it in the act.
    
    For #27993.
    Updates #29385 (may fix it).
    
    Change-Id: Ic71c10701229febb4ddf8c104fb10e06d84b122e
    Reviewed-on: https://go-review.googlesource.com/c/156017
    Run-TryBot: Austin Clements <austin@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
    8e639611
mgcwork.go 14.3 KB