diff options
| author | Russ Cox <rsc@golang.org> | 2015-06-07 22:59:29 -0400 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2015-06-11 18:15:21 +0000 |
| commit | d57c889ae8bdfdddbfb242f90b90f649988a720e (patch) | |
| tree | 97d84c2c17ff8e3171783859a0b99de56967b820 /src/runtime/malloc.go | |
| parent | a788c913fa667a723ca55539b41fee30291ed92e (diff) | |
| download | go-d57c889ae8bdfdddbfb242f90b90f649988a720e.tar.xz | |
runtime: wait to update arena_used until after mapping bitmap
This avoids a race with gcmarkwb_m that was leading to faults.
Fixes #10212.
Change-Id: I6fcf8d09f2692227063ce29152cb57366ea22487
Reviewed-on: https://go-review.googlesource.com/10816
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/malloc.go')
| -rw-r--r-- | src/runtime/malloc.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 2d7e55643f..d182ed62dc 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -418,9 +418,9 @@ func mHeap_SysAlloc(h *mheap, n uintptr) unsafe.Pointer { // Keep taking from our reservation. p := h.arena_used sysMap((unsafe.Pointer)(p), n, h.arena_reserved, &memstats.heap_sys) - h.arena_used += n - mHeap_MapBits(h) - mHeap_MapSpans(h) + mHeap_MapBits(h, p+n) + mHeap_MapSpans(h, p+n) + h.arena_used = p+n if raceenabled { racemapshadow((unsafe.Pointer)(p), n) } @@ -454,12 +454,12 @@ func mHeap_SysAlloc(h *mheap, n uintptr) unsafe.Pointer { p_end := p + p_size p += -p & (_PageSize - 1) if uintptr(p)+n > uintptr(h.arena_used) { - h.arena_used = p + n + mHeap_MapBits(h, p+n) + mHeap_MapSpans(h, p+n) + h.arena_used = p+n if p_end > h.arena_end { h.arena_end = p_end } - mHeap_MapBits(h) - mHeap_MapSpans(h) if raceenabled { racemapshadow((unsafe.Pointer)(p), n) } |
