Commit 3590d9ce authored by Keith Randall's avatar Keith Randall

runtime: set sweepgen atomically before updating span state

Sweepone may be running while a new span is allocating.  It
must not see the state updated while the sweepgen is unset.

Fixes #8399

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/118050043
parent 748e5db9
......@@ -189,13 +189,13 @@ mheap_alloc(MHeap *h, uintptr npage, int32 sizeclass, bool large)
if(s != nil) {
// Record span info, because gc needs to be
// able to map interior pointer to containing span.
runtime·atomicstore(&s->sweepgen, h->sweepgen);
s->state = MSpanInUse;
s->freelist = nil;
s->ref = 0;
s->sizeclass = sizeclass;
s->elemsize = (sizeclass==0 ? s->npages<<PageShift : runtime·class_to_size[sizeclass]);
s->types.compression = MTypes_Empty;
s->sweepgen = h->sweepgen;
// update stats, sweep lists
if(large) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment