diff options
| author | Keith Randall <khr@golang.org> | 2014-10-08 15:57:20 -0700 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2014-10-08 15:57:20 -0700 |
| commit | 91e8554b8b9edfb4b05b2c04a50daf4df8ffed7b (patch) | |
| tree | 77e0025cd3fc6f5796a5776603c50e2452407101 /src/runtime/runtime.h | |
| parent | 6920b2a1f93a2ff6876eafc7f8747e82aa59d015 (diff) | |
| download | go-91e8554b8b9edfb4b05b2c04a50daf4df8ffed7b.tar.xz | |
runtime: delay freeing of shrunk stacks until gc is done.
This change prevents confusion in the garbage collector.
The collector wants to make sure that every pointer it finds
isn't junk. Its criteria for junk is (among others) points
to a "free" span.
Because the stack shrinker modifies pointers in the heap,
there is a race condition between the GC scanner and the
shrinker. The GC scanner can see old pointers (pointers to
freed stacks). In particular this happens with SudoG.elem
pointers.
Normally this is not a problem, as pointers into stack spans
are ok. But if the freed stack is the last one in its span,
the span is marked as "free" instead of "contains stacks".
This change makes sure that even if the GC scanner sees
an old pointer, the span into which it points is still
marked as "contains stacks", and thus the GC doesn't
complain about it.
This change will make the GC pause a tiny bit slower, as
the stack freeing now happens in serial with the mark pause.
We could delay the freeing until the mutators start back up,
but this is the simplest change for now.
TBR=dvyukov
CC=golang-codereviews
https://golang.org/cl/158750043
Diffstat (limited to 'src/runtime/runtime.h')
| -rw-r--r-- | src/runtime/runtime.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 27a809a07e..a84a32525e 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -852,6 +852,7 @@ void runtime·stackinit(void); Stack runtime·stackalloc(uint32); void runtime·stackfree(Stack); void runtime·shrinkstack(G*); +void runtime·shrinkfinish(void); MCache* runtime·allocmcache(void); void runtime·freemcache(MCache*); void runtime·mallocinit(void); |
