• Russ Cox's avatar
    cmd/gc, runtime: treat slices and strings like pointers in garbage collection · 613383c7
    Russ Cox authored
    Before, a slice with cap=0 or a string with len=0 might have its
    base pointer pointing beyond the actual slice/string data into
    the next block. The collector had to ignore slices and strings with
    cap=0 in order to avoid misinterpreting the base pointer.
    
    Now, a slice with cap=0 or a string with len=0 still has a base
    pointer pointing into the actual slice/string data, no matter what.
    The collector can now always scan the pointer, which means
    strings and slices are no longer special.
    
    Fixes #8404.
    
    LGTM=khr, josharian
    R=josharian, khr, dvyukov
    CC=golang-codereviews
    https://golang.org/cl/112570044
    613383c7
mgc0.c 58.8 KB