• Russ Cox's avatar
    runtime: fix two garbage collector bugs · 02f89331
    Russ Cox authored
    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/2340Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
    02f89331
malloc.go 29.9 KB