Move store after __asan_unpoison in __zipos_alloc (#1135)

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-10 23:04:03 -04:00 committed by GitHub
parent cf9a1f7f33
commit 3e16e59f72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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