• Ian Lance Taylor's avatar
    runtime: unlock sched lock when checkdead throws due to a deadlock · 4ff45821
    Ian Lance Taylor authored
    I was doing some testing with GODEBUG=schedtrace=1,scheddetail=1 and I
    noticed that the program hung after a throw with "all goroutines are
    asleep". This is because when doing a throw or fatal panic with schedtrace
    the panic code does a final schedtrace, which needs to acquire the
    scheduler lock. The checkdead function is always called with the scheduler
    lock held. So checkdead would throw with the scheduler lock held, then
    the panic code would call schedtrace, which would block trying to acquire
    the scheduler lock.
    
    This problem will only happen for people debugging the runtime, but
    it's easy to avoid by having checkdead unlock the scheduler lock before
    it throws. I only did this for the throws that can happen for a normal
    program, not for throws that indicate some corruption in the scheduler data.
    
    Change-Id: Ic62277b3ca6bee6f0fca8d5eb516c59cb67855cb
    Reviewed-on: https://go-review.googlesource.com/c/go/+/204778
    Run-TryBot: Ian Lance Taylor <iant@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
    4ff45821
proc.go 149 KB