aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-02-19 16:21:42 -0500
committerRuss Cox <rsc@golang.org>2015-02-19 21:33:06 +0000
commit5254b7e9cefb597a9b9ce5137d6e5248a14d8d73 (patch)
treed4cbc9e2c6256c3fd952f7afd7db1d0588bb0db0
parent6c4b54f409b537ce60e539e2ec1c56abfe1e145c (diff)
downloadgo-5254b7e9cefb597a9b9ce5137d6e5248a14d8d73.tar.gz
go-5254b7e9cefb597a9b9ce5137d6e5248a14d8d73.zip
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 <rlh@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
-rw-r--r--src/runtime/mgc.go17
1 files changed, 8 insertions, 9 deletions
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