// Find additional pointers that point into the stack from the heap.
// Currently this includes defers and panics. See also function copystack.
- // Find and trace all defer arguments.
- tracebackdefers(gp, scanframe, nil)
-
// Find and trace other pointers in defer records.
for d := gp._defer; d != nil; d = d.link {
if d.fn != nil {
- // tracebackdefers above does not scan the func value, which could
- // be a stack allocated closure. See issue 30453.
+ // Scan the func value, which could be a stack allocated closure.
+ // See issue 30453.
scanblock(uintptr(unsafe.Pointer(&d.fn)), sys.PtrSize, &oneptrmask[0], gcw, &state)
}
if d.link != nil {
adjustpointer(adjinfo, unsafe.Pointer(&d.varp))
adjustpointer(adjinfo, unsafe.Pointer(&d.fd))
}
-
- // Adjust defer argument blocks the same way we adjust active stack frames.
- // Note: this code is after the loop above, so that if a defer record is
- // stack allocated, we work on the copy in the new stack.
- tracebackdefers(gp, adjustframe, noescape(unsafe.Pointer(adjinfo)))
}
func adjustpanics(gp *g, adjinfo *adjustinfo) {
const usesLR = sys.MinFrameSize > 0
-// Traceback over the deferred function calls.
-// Report them like calls that have been invoked but not started executing yet.
-func tracebackdefers(gp *g, callback func(*stkframe, unsafe.Pointer) bool, v unsafe.Pointer) {
- var frame stkframe
- for d := gp._defer; d != nil; d = d.link {
- fn := d.fn
- if fn == nil {
- // Defer of nil function. Args don't matter.
- frame.pc = 0
- frame.fn = funcInfo{}
- frame.argp = 0
- frame.arglen = 0
- frame.argmap = nil
- } else {
- frame.pc = fn.fn
- f := findfunc(frame.pc)
- if !f.valid() {
- print("runtime: unknown pc in defer ", hex(frame.pc), "\n")
- throw("unknown pc")
- }
- frame.fn = f
- frame.argp = 0
- frame.arglen = 0
- frame.argmap = nil
- }
- frame.continpc = frame.pc
- if !callback((*stkframe)(noescape(unsafe.Pointer(&frame))), v) {
- return
- }
- }
-}
-
const sizeofSkipFunction = 256
// Generic traceback. Handles runtime stack prints (pcbuf == nil),