diff options
| author | Dmitriy Vyukov <dvyukov@google.com> | 2014-03-26 19:06:15 +0400 |
|---|---|---|
| committer | Dmitriy Vyukov <dvyukov@google.com> | 2014-03-26 19:06:15 +0400 |
| commit | 7c75a862b4df306a2573d1aa966d68803bc8b4e7 (patch) | |
| tree | 0fddeb2c3e9fcbfbcbfd21e190abfd22ce860f4a /src/pkg/runtime/stack.c | |
| parent | d89a73837878fa16697e98ff1adf249eef5eaa05 (diff) | |
| download | go-7c75a862b4df306a2573d1aa966d68803bc8b4e7.tar.xz | |
runtime: eliminate false retention due to m->moreargp/morebuf
m->moreargp/morebuf were not cleared in case of preemption and stack growing,
it can lead to persistent leaks of large memory blocks.
It seems to fix the sync.Pool finalizer failures. I've run the test 500'000 times
w/o a single failure; previously it would fail dozens of times.
Fixes #7633.
Fixes #7533.
LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, khr, rsc
https://golang.org/cl/80480044
Diffstat (limited to 'src/pkg/runtime/stack.c')
| -rw-r--r-- | src/pkg/runtime/stack.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/pkg/runtime/stack.c b/src/pkg/runtime/stack.c index 6e5d9f1f58..4d21c719b0 100644 --- a/src/pkg/runtime/stack.c +++ b/src/pkg/runtime/stack.c @@ -608,7 +608,8 @@ runtime·newstack(void) uintptr sp; uintptr *src, *dst, *dstend; G *gp; - Gobuf label; + Gobuf label, morebuf; + void *moreargp; bool newstackcall; if(m->forkstackguard) @@ -627,6 +628,12 @@ runtime·newstack(void) framesize = m->moreframesize; argsize = m->moreargsize; + moreargp = m->moreargp; + m->moreargp = nil; + morebuf = m->morebuf; + m->morebuf.pc = (uintptr)nil; + m->morebuf.lr = (uintptr)nil; + m->morebuf.sp = (uintptr)nil; gp->status = Gwaiting; gp->waitreason = "stack split"; newstackcall = framesize==1; @@ -727,13 +734,9 @@ runtime·newstack(void) top->stackbase = gp->stackbase; top->stackguard = gp->stackguard; - top->gobuf = m->morebuf; - top->argp = m->moreargp; + top->gobuf = morebuf; + top->argp = moreargp; top->argsize = argsize; - m->moreargp = nil; - m->morebuf.pc = (uintptr)nil; - m->morebuf.lr = (uintptr)nil; - m->morebuf.sp = (uintptr)nil; // copy flag from panic top->panic = gp->ispanic; |
