mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: fix cgo signals detection
CL 64070 removed lockOSThread from the cgocall path, but didn't update the signal-in-cgo detection in sighandler. As a result, signals that arrive during a cgo call are treated like they arrived during Go execution, breaking the traceback. Update the cgo detection to fix the backtrace. Fixes #47522 Change-Id: I61d77ba6465f55e3e6187246d79675ba8467ec23 Reviewed-on: https://go-review.googlesource.com/c/go/+/339989 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
3a0cd11214
commit
091db6392d
5 changed files with 100 additions and 4 deletions
|
|
@ -688,9 +688,11 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
|
|||
}
|
||||
|
||||
print("PC=", hex(c.sigpc()), " m=", _g_.m.id, " sigcode=", c.sigcode(), "\n")
|
||||
if _g_.m.lockedg != 0 && _g_.m.ncgo > 0 && gp == _g_.m.g0 {
|
||||
if _g_.m.incgo && gp == _g_.m.g0 && _g_.m.curg != nil {
|
||||
print("signal arrived during cgo execution\n")
|
||||
gp = _g_.m.lockedg.ptr()
|
||||
// Switch to curg so that we get a traceback of the Go code
|
||||
// leading up to the cgocall, which switched from curg to g0.
|
||||
gp = _g_.m.curg
|
||||
}
|
||||
if sig == _SIGILL || sig == _SIGFPE {
|
||||
// It would be nice to know how long the instruction is.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue