]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: do not unmap work.spans until after checkmark phase
authorRuss Cox <rsc@golang.org>
Thu, 19 Feb 2015 21:21:42 +0000 (16:21 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 19 Feb 2015 21:33:06 +0000 (21:33 +0000)
This is causing crashes.

Change-Id: I1832f33d114bc29894e491dd2baac45d7ab3a50d
Reviewed-on: https://go-review.googlesource.com/5330
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/mgc.go

index 70661e46d0984b9323dc0db24507a6eba082ae51..75d6b9158e3525dd2e8e072a6614a61f20f5b463 100644 (file)
@@ -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