mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: clear stale values from G.param and SudoG.elem
This change was necessary on the dev.garbage branch to keep the garbage collector from seeing pointers into invalid heap areas. On this default (Go 1.4) branch, the change removes some possibility for memory leaks. LGTM=khr R=golang-codereviews, khr CC=golang-codereviews, iant, r, rlh https://golang.org/cl/155760043
This commit is contained in:
parent
3ffd29fb2c
commit
0120f8378d
4 changed files with 27 additions and 2 deletions
|
|
@ -148,6 +148,9 @@ func acquireSudog() *sudog {
|
|||
c := gomcache()
|
||||
s := c.sudogcache
|
||||
if s != nil {
|
||||
if s.elem != nil {
|
||||
gothrow("acquireSudog: found s.elem != nil in cache")
|
||||
}
|
||||
c.sudogcache = s.next
|
||||
return s
|
||||
}
|
||||
|
|
@ -168,6 +171,13 @@ func acquireSudog() *sudog {
|
|||
|
||||
//go:nosplit
|
||||
func releaseSudog(s *sudog) {
|
||||
if s.elem != nil {
|
||||
gothrow("runtime: sudog with non-nil elem")
|
||||
}
|
||||
gp := getg()
|
||||
if gp.param != nil {
|
||||
gothrow("runtime: releaseSudog with non-nil gp.param")
|
||||
}
|
||||
c := gomcache()
|
||||
s.next = c.sudogcache
|
||||
c.sudogcache = s
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue