mirror of
https://github.com/golang/go
synced 2024-11-19 10:04:56 -07:00
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
This commit is contained in:
parent
748e5db96d
commit
3590d9ce69
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user