]> Cypherpunks repositories - gostls13.git/commit
runtime: scan stacks conservatively at async safe points
authorAustin Clements <austin@google.com>
Thu, 10 Oct 2019 18:38:15 +0000 (14:38 -0400)
committerAustin Clements <austin@google.com>
Sat, 2 Nov 2019 21:51:16 +0000 (21:51 +0000)
commitd16ec137568fb20e674a99c265e7c340c065dd69
tree7e61729e505094e6fc1c7336dd48da5fc9c3e041
parenta3ffb0d9eb948409c0898c6b1803401c9bc68ed4
runtime: scan stacks conservatively at async safe points

This adds support for scanning the stack when a goroutine is stopped
at an async safe point. This is not yet lit up because asyncPreempt is
not yet injected, but prepares us for that.

This works by conservatively scanning the registers dumped in the
frame of asyncPreempt and its parent frame, which was stopped at an
asynchronous safe point.

Conservative scanning works by only marking words that are pointers to
valid, allocated heap objects. One complication is pointers to stack
objects. In this case, we can't determine if the stack object is still
"allocated" or if it was freed by an earlier GC. Hence, we need to
propagate the conservative-ness of scanning stack objects: if all
pointers found to a stack object were found via conservative scanning,
then the stack object itself needs to be scanned conservatively, since
its pointers may point to dead objects.

For #10958, #24543.

Change-Id: I7ff84b058c37cde3de8a982da07002eaba126fd6
Reviewed-on: https://go-review.googlesource.com/c/go/+/201761
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/internal/objabi/funcid.go
src/runtime/mgc.go
src/runtime/mgcmark.go
src/runtime/mgcstack.go
src/runtime/symtab.go