-
Keith Randall authored
This change prevents confusion in the garbage collector. The collector wants to make sure that every pointer it finds isn't junk. Its criteria for junk is (among others) points to a "free" span. Because the stack shrinker modifies pointers in the heap, there is a race condition between the GC scanner and the shrinker. The GC scanner can see old pointers (pointers to freed stacks). In particular this happens with SudoG.elem pointers. Normally this is not a problem, as pointers into stack spans are ok. But if the freed stack is the last one in its span, the span is marked as "free" instead of "contains stacks". This change makes sure that even if the GC scanner sees an old pointer, the span into which it points is still marked as "contains stacks", and thus the GC doesn't complain about it. This change will make the GC pause a tiny bit slower, as the stack freeing now happens in serial with the mark pause. We could delay the freeing until the mutators start back up, but this is the simplest change for now. TBR=dvyukov CC=golang-codereviews https://golang.org/cl/158750043
91e8554b