diff options
| author | Michael Pratt <mpratt@google.com> | 2021-08-04 17:33:50 -0400 |
|---|---|---|
| committer | Michael Pratt <mpratt@google.com> | 2021-10-26 21:32:57 +0000 |
| commit | 86f6bf18b013d570e89f57c2decaddca5ce2a847 (patch) | |
| tree | 60c69df18411191c525e91278bea1624a32ee654 /src/runtime/traceback.go | |
| parent | 091db6392da5913e4bd4806215102e461dc5649c (diff) | |
| download | go-86f6bf18b013d570e89f57c2decaddca5ce2a847.tar.xz | |
runtime: handle async fatal signals in VDSO
If we receive an async signal while running in the VDSO, such as a
SIGABRT or SIGSEGV sent from another process, we fail to print the
stacktrace with "runtime: unknown pc <vdso PC>".
We already have machinery to handle SIGPROF in the VDSO, but it isn't
hooked up for other signals. Add it to the general signal traceback
path.
This case is covered by TestSegv by making the test more strict w.r.t.
accepted output.
Fixes #47537
Change-Id: I755585f70e0c23e207e135bc6bd2aa68298e5d24
Reviewed-on: https://go-review.googlesource.com/c/go/+/339990
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>
Diffstat (limited to 'src/runtime/traceback.go')
| -rw-r--r-- | src/runtime/traceback.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/runtime/traceback.go b/src/runtime/traceback.go index 530d572095..7e1b14ccf2 100644 --- a/src/runtime/traceback.go +++ b/src/runtime/traceback.go @@ -777,16 +777,23 @@ func traceback1(pc, sp, lr uintptr, gp *g, flags uint) { printCgoTraceback(&cgoCallers) } - var n int if readgstatus(gp)&^_Gscan == _Gsyscall { // Override registers if blocked in system call. pc = gp.syscallpc sp = gp.syscallsp flags &^= _TraceTrap } + if gp.m != nil && gp.m.vdsoSP != 0 { + // Override registers if running in VDSO. This comes after the + // _Gsyscall check to cover VDSO calls after entersyscall. + pc = gp.m.vdsoPC + sp = gp.m.vdsoSP + flags &^= _TraceTrap + } + // Print traceback. By default, omits runtime frames. // If that means we print nothing at all, repeat forcing all frames printed. - n = gentraceback(pc, sp, lr, gp, 0, nil, _TracebackMaxFrames, nil, nil, flags) + n := gentraceback(pc, sp, lr, gp, 0, nil, _TracebackMaxFrames, nil, nil, flags) if n == 0 && (flags&_TraceRuntimeFrames) == 0 { n = gentraceback(pc, sp, lr, gp, 0, nil, _TracebackMaxFrames, nil, nil, flags|_TraceRuntimeFrames) } |
