Move store after __asan_unpoison in __zipos_alloc

Previously, the atomic store looked like it was happening while the
struct's memory was still poisoned. I was unable to observe any issues
with this, but this change seems to make the code more obviously correct
(at the cost of a redundant atomic store to zeroed space in case the map
needed to be extended.)
This commit is contained in:
Jōshin 2024-04-03 14:29:07 -04:00
parent b9d6e6e348
commit c860be3de7
No known key found for this signature in database

View file

@ -114,7 +114,6 @@ StartOver:
while ((h = *ph)) { while ((h = *ph)) {
if (h->mapsize >= mapsize) { if (h->mapsize >= mapsize) {
if (!_cmpxchg(ph, h, h->next)) goto StartOver; if (!_cmpxchg(ph, h, h->next)) goto StartOver;
atomic_store_explicit(&h->refs, 0, memory_order_relaxed);
break; break;
} }
ph = &h->next; ph = &h->next;
@ -130,6 +129,7 @@ StartOver:
kAsanHeapOverrun); kAsanHeapOverrun);
} }
if (h) { if (h) {
atomic_store_explicit(&h->refs, 0, memory_order_relaxed);
h->size = size; h->size = size;
h->zipos = zipos; h->zipos = zipos;
h->mapsize = mapsize; h->mapsize = mapsize;