[PATCH] Fix an error on invalid deallocation in ASan allocator

Alexey Samsonov samsonov at google.com
Thu Mar 21 08:06:36 PDT 2013



================
Comment at: lib/asan/asan_allocator2.cc:426
@@ -424,3 +425,3 @@
   // Flip the chunk_state atomically to avoid race on double-free.
-  u8 old_chunk_state = atomic_exchange((atomic_uint8_t*)m, CHUNK_QUARANTINE,
-                                       memory_order_relaxed);
+  if (!atomic_compare_exchange_weak((atomic_uint8_t*)m, &old_chunk_state,
+                                    CHUNK_QUARANTINE, memory_order_relaxed)) {
----------------
Dmitry Vyukov wrote:
> This needs to be _strong if you don't use loop. _weak can fail spuriously.
Done


http://llvm-reviews.chandlerc.com/D565



More information about the llvm-commits mailing list