From 02f89331c2ec09923806611bc1a8fbb2ffcbcca5 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 5 Jan 2015 15:02:09 -0500 Subject: runtime: fix two garbage collector bugs First, call clearcheckmarks immediately after changing checkmark, so that there is less time when the checkmark flag and the bitmap are inconsistent. The tiny gap between the two lines is fine, because the world is stopped. Before, the gap was much larger and included such code as "go bgsweep()", which allocated. Second, modify gcphase only when the world is stopped. As written, gcscan_m was changing gcphase from 0 to GCscan and back to 0 while other goroutines were running. Another goroutine running at the same time might decide to sleep, see GCscan, call gcphasework, and start "helping" by scanning its stack. That's fine, except that if gcphase flips back to 0 as the goroutine calls scanblock, it will start draining the work buffers prematurely. Both of these were found wbshadow=2 (and a lot of hard work). Eventually that will run automatically, but right now it still doesn't quite work for all.bash, due to mmap conflicts with pthread-created threads. Change-Id: I99aa8210cff9c6e7d0a1b62c75be32a23321897b Reviewed-on: https://go-review.googlesource.com/2340 Reviewed-by: Rick Hudson --- src/runtime/malloc.go | 1 + 1 file changed, 1 insertion(+) (limited to 'src/runtime/malloc.go') diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 22c0dfe3a4..772d3309d2 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -493,6 +493,7 @@ func gogc(force int32) { systemstack(stoptheworld) systemstack(finishsweep_m) // finish sweep before we start concurrent scan. if force == 0 { // Do as much work concurrently as possible + gcphase = _GCscan systemstack(starttheworld) gctimer.cycle.scan = nanotime() // Do a concurrent heap scan before we stop the world. -- cgit v1.3