diff options
| author | Russ Cox <rsc@golang.org> | 2011-02-16 13:21:20 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2011-02-16 13:21:20 -0500 |
| commit | 250977690bbd86b7af22b4feb69c409996d3d3f5 (patch) | |
| tree | 9f9086ee85a94eb8083f1b685ed916beecc9c61c /src/pkg/runtime/malloc.goc | |
| parent | 677935034962a5a89eb92fdfe5d96b41cf5e6b71 (diff) | |
| download | go-250977690bbd86b7af22b4feb69c409996d3d3f5.tar.xz | |
runtime: fix memory allocator for GOMAXPROCS > 1
Bitmaps were not being updated safely.
Depends on 4188053.
Fixes #1504.
May fix issue 1479.
R=r, r2
CC=golang-dev
https://golang.org/cl/4184048
Diffstat (limited to 'src/pkg/runtime/malloc.goc')
| -rw-r--r-- | src/pkg/runtime/malloc.goc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/pkg/runtime/malloc.goc b/src/pkg/runtime/malloc.goc index 70b85d68d7..745e18ca0d 100644 --- a/src/pkg/runtime/malloc.goc +++ b/src/pkg/runtime/malloc.goc @@ -146,6 +146,9 @@ runtime·free(void *v) // Large object. size = s->npages<<PageShift; *(uintptr*)(s->start<<PageShift) = 1; // mark as "needs to be zeroed" + // Must mark v freed before calling unmarkspan and MHeap_Free: + // they might coalesce v into other spans and change the bitmap further. + runtime·markfreed(v, size); runtime·unmarkspan(v, 1<<PageShift); runtime·MHeap_Free(&runtime·mheap, s, 1); } else { @@ -154,10 +157,13 @@ runtime·free(void *v) size = runtime·class_to_size[sizeclass]; if(size > sizeof(uintptr)) ((uintptr*)v)[1] = 1; // mark as "needs to be zeroed" + // Must mark v freed before calling MCache_Free: + // it might coalesce v and other blocks into a bigger span + // and change the bitmap further. + runtime·markfreed(v, size); mstats.by_size[sizeclass].nfree++; runtime·MCache_Free(c, v, sizeclass, size); } - runtime·markfreed(v, size); mstats.alloc -= size; if(prof) runtime·MProf_Free(v, size); |
