fix potential A-B-A problem with segment abandonment; noticed by Manual Poeter and Sam Gross

This commit is contained in:
daan 2020-01-08 17:45:38 -08:00
parent 5d2f111f64
commit 683d8998d4
3 changed files with 60 additions and 28 deletions

View file

@ -234,7 +234,7 @@ typedef struct mi_segment_s {
// segment fields
struct mi_segment_s* next; // must be the first segment field -- see `segment.c:segment_alloc`
struct mi_segment_s* prev;
volatile _Atomic(struct mi_segment_s*) abandoned_next;
struct mi_segment_s* abandoned_next;
size_t abandoned; // abandoned pages (i.e. the original owning thread stopped) (`abandoned <= used`)
size_t used; // count of pages in use (`used <= capacity`)
size_t capacity; // count of available pages (`#free + used`)