aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/stack.c
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2014-03-14 23:25:48 +0400
committerDmitriy Vyukov <dvyukov@google.com>2014-03-14 23:25:48 +0400
commit8d321625fdae77d7e4a8c1681fe90bd893b9cdd2 (patch)
tree4bc303a3b7d46b1039acc7e5486854033a6a6a11 /src/pkg/runtime/stack.c
parentf210fd1fa905ad381c8cb358ed7c004ec582f90f (diff)
downloadgo-8d321625fdae77d7e4a8c1681fe90bd893b9cdd2.tar.xz
runtime: fix spans corruption
The problem was that spans end up in wrong lists after split (e.g. in h->busy instead of h->central->empty). Also the span can be non-swept before split, I don't know what it can cause, but it's safer to operate on swept spans. Fixes #7544. R=golang-codereviews, rsc CC=golang-codereviews, khr https://golang.org/cl/76160043
Diffstat (limited to 'src/pkg/runtime/stack.c')
-rw-r--r--src/pkg/runtime/stack.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/pkg/runtime/stack.c b/src/pkg/runtime/stack.c
index c0b98634d7..c73991470e 100644
--- a/src/pkg/runtime/stack.c
+++ b/src/pkg/runtime/stack.c
@@ -838,15 +838,7 @@ runtime·shrinkstack(G *gp)
// First, we trick malloc into thinking
// we allocated the stack as two separate half-size allocs. Then the
// free() call does the rest of the work for us.
- if(oldsize == PageSize) {
- // convert span of 1 PageSize object to a span of 2
- // PageSize/2 objects.
- span->ref = 2;
- span->sizeclass = runtime·SizeToClass(PageSize/2);
- span->elemsize = PageSize/2;
- } else {
- // convert span of n>1 pages into two spans of n/2 pages each.
- runtime·MHeap_SplitSpan(&runtime·mheap, span);
- }
+ runtime·MSpan_EnsureSwept(span);
+ runtime·MHeap_SplitSpan(&runtime·mheap, span);
runtime·free(oldstk);
}