diff options
author | Cherry Zhang <cherryyz@google.com> | 2019-02-27 12:34:20 -0500 |
---|---|---|
committer | Cherry Zhang <cherryyz@google.com> | 2019-03-01 16:21:29 +0000 |
commit | 4f4c2a79d4f952b96d58aec2926b4c894245071b (patch) | |
tree | 41c5b7f6bb790fa44f6d09a78725ba8590400f86 /src/runtime/mgcmark.go | |
parent | c04e47f82159f1010d7403276b3dff5ab836fd00 (diff) | |
download | go-4f4c2a79d4f952b96d58aec2926b4c894245071b.tar.gz go-4f4c2a79d4f952b96d58aec2926b4c894245071b.zip |
runtime: scan defer closure in stack scan
With stack objects, when we scan the stack, it scans defers with
tracebackdefers, but it seems to me that tracebackdefers doesn't
include the func value itself, which could be a stack allocated
closure. Scan it explicitly.
Alternatively, we can change tracebackdefers to include the func
value, which in turn needs to change the type of stkframe.
Fixes #30453.
Change-Id: I55a6e43264d6952ab2fa5c638bebb89fdc410e2b
Reviewed-on: https://go-review.googlesource.com/c/164118
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/mgcmark.go')
-rw-r--r-- | src/runtime/mgcmark.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/runtime/mgcmark.go b/src/runtime/mgcmark.go index 022cc8d7d7..cc4e7d06d3 100644 --- a/src/runtime/mgcmark.go +++ b/src/runtime/mgcmark.go @@ -713,6 +713,13 @@ func scanstack(gp *g, gcw *gcWork) { // Find additional pointers that point into the stack from the heap. // Currently this includes defers and panics. See also function copystack. tracebackdefers(gp, scanframe, nil) + for d := gp._defer; d != nil; d = d.link { + // tracebackdefers above does not scan the func value, which could + // be a stack allocated closure. See issue 30453. + if d.fn != nil { + scanblock(uintptr(unsafe.Pointer(&d.fn)), sys.PtrSize, &oneptrmask[0], gcw, &state) + } + } if gp._panic != nil { state.putPtr(uintptr(unsafe.Pointer(gp._panic))) } |