From: Russ Cox Date: Thu, 19 Feb 2015 21:21:42 +0000 (-0500) Subject: runtime: do not unmap work.spans until after checkmark phase X-Git-Tag: go1.5beta1~1943 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=5254b7e9cefb597a9b9ce5137d6e5248a14d8d73;p=gostls13.git runtime: do not unmap work.spans until after checkmark phase This is causing crashes. Change-Id: I1832f33d114bc29894e491dd2baac45d7ab3a50d Reviewed-on: https://go-review.googlesource.com/5330 Reviewed-by: Rick Hudson Reviewed-by: Russ Cox --- diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index 70661e46d0..75d6b9158e 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -616,24 +616,23 @@ func gc(start_time int64, eagersweep bool) { sweep.npausesweep = 0 } - // See the comment in the beginning of this function as to why we need the following. - // Even if this is still stop-the-world, a concurrent exitsyscall can allocate a stack from heap. - lock(&mheap_.lock) - // Free the old cached mark array if necessary. - if work.spans != nil && &work.spans[0] != &h_allspans[0] { - sysFree(unsafe.Pointer(&work.spans[0]), uintptr(len(work.spans))*unsafe.Sizeof(work.spans[0]), &memstats.other_sys) - } - if debug.gccheckmark > 0 { if !checkmarkphase { // first half of two-pass; don't set up sweep - unlock(&mheap_.lock) return } checkmarkphase = false // done checking marks clearCheckmarks() } + // See the comment in the beginning of this function as to why we need the following. + // Even if this is still stop-the-world, a concurrent exitsyscall can allocate a stack from heap. + lock(&mheap_.lock) + // Free the old cached mark array if necessary. + if work.spans != nil && &work.spans[0] != &h_allspans[0] { + sysFree(unsafe.Pointer(&work.spans[0]), uintptr(len(work.spans))*unsafe.Sizeof(work.spans[0]), &memstats.other_sys) + } + // Cache the current array for sweeping. mheap_.gcspans = mheap_.allspans mheap_.sweepgen += 2