[llvm-commits] [compiler-rt] r161661 - /compiler-rt/trunk/lib/asan/asan_malloc_mac.cc
Alexander Potapenko
glider at google.com
Fri Aug 10 04:33:02 PDT 2012
Author: glider
Date: Fri Aug 10 06:33:01 2012
New Revision: 161661
URL: http://llvm.org/viewvc/llvm-project?rev=161661&view=rev
Log:
Temporary fix for http://code.google.com/p/address-sanitizer/issues/detail?id=99:
when trying to free memory that actually belongs to the system purgeable zone, use malloc_zone_free(malloc_default_purgeable_zone(), ptr) instead of asan_free().
Modified:
compiler-rt/trunk/lib/asan/asan_malloc_mac.cc
Modified: compiler-rt/trunk/lib/asan/asan_malloc_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_malloc_mac.cc?rev=161661&r1=161660&r2=161661&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_malloc_mac.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_malloc_mac.cc Fri Aug 10 06:33:01 2012
@@ -161,7 +161,15 @@
if (!ptr) return;
if (!flags()->mac_ignore_invalid_free || asan_mz_size(ptr)) {
GET_STACK_TRACE_HERE_FOR_FREE(ptr);
- asan_free(ptr, &stack);
+ malloc_zone_t *zone_ptr = malloc_zone_from_ptr(ptr);
+ if (zone_ptr == system_purgeable_zone) {
+ // Allocations from malloc_default_purgeable_zone() done before
+ // __asan_init() may be occasionally freed via free_common().
+ // See http://code.google.com/p/address-sanitizer/issues/detail?id=99.
+ malloc_zone_free(zone_ptr, ptr);
+ } else {
+ asan_free(ptr, &stack);
+ }
} else {
// Let us just leak this memory for now.
GET_STACK_TRACE_HERE_FOR_FREE(ptr);
More information about the llvm-commits
mailing list