mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: preempt more aggressively when panicking
When we are crashing from an unrecovered panic, we freeze the world, and print stack traces for all goroutines if GOTRACEBACK is set to a high enough level. Freezing the world is best effort, so there could still be goroutines that are not preempted, and so its stack trace is unavailable and printed as "goroutine running on other thread". As we're crashing and not resuming execution on preempted goroutines, we can make preemption more aggressive, preempting cases that are not safe for resumption or stack scanning. This may make goroutines more likely to be preempted in freezing the world and have their stacks available. Change-Id: Ie16269e2a05e007efa61368b695addc28d7a97ee Reviewed-on: https://go-review.googlesource.com/c/go/+/546135 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
This commit is contained in:
parent
b32ec6c961
commit
13766fe7d8
3 changed files with 15 additions and 4 deletions
|
|
@ -342,7 +342,7 @@ func doSigPreempt(gp *g, ctxt *sigctxt) {
|
|||
// Check if this G wants to be preempted and is safe to
|
||||
// preempt.
|
||||
if wantAsyncPreempt(gp) {
|
||||
if ok, newpc := isAsyncSafePoint(gp, ctxt.sigpc(), ctxt.sigsp(), ctxt.siglr()); ok {
|
||||
if ok, newpc := isAsyncSafePoint(gp, ctxt.sigpc(), ctxt.sigsp(), ctxt.siglr(), panicking.Load() != 0); ok {
|
||||
// Adjust the PC and inject a call to asyncPreempt.
|
||||
ctxt.pushCall(abi.FuncPCABI0(asyncPreempt), newpc)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue