[llvm-commits] [compiler-rt] r159713 - /compiler-rt/trunk/lib/asan/asan_malloc_mac.cc
Alexander Potapenko
glider at google.com
Wed Jul 4 06:58:07 PDT 2012
Author: glider
Date: Wed Jul 4 08:58:07 2012
New Revision: 159713
URL: http://llvm.org/viewvc/llvm-project?rev=159713&view=rev
Log:
Do not call malloc_zone_from_ptr() for the pointers passed to mz_size() and mz_free().
These callbacks assume that the memory belongs to asan_zone, so it's incorrect to pass it to another one.
If a need for this appears (e.g. system libraries free the memory using wrong zone), it should be documented.
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=159713&r1=159712&r2=159713&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_malloc_mac.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_malloc_mac.cc Wed Jul 4 08:58:07 2012
@@ -82,12 +82,6 @@
// TODO(glider): the mz_* functions should be united with the Linux wrappers,
// as they are basically copied from there.
size_t mz_size(malloc_zone_t* zone, const void* ptr) {
- // Fast path: check whether this pointer belongs to the original malloc zone.
- // We cannot just call malloc_zone_from_ptr(), because it in turn
- // calls our mz_size().
- if (system_malloc_zone) {
- if ((system_malloc_zone->size)(system_malloc_zone, ptr)) return 0;
- }
return asan_mz_size(ptr);
}
@@ -151,14 +145,6 @@
void ALWAYS_INLINE free_common(void *context, void *ptr) {
if (!ptr) return;
- malloc_zone_t *orig_zone = malloc_zone_from_ptr(ptr);
- // For some reason Chromium calls mz_free() for pointers that belong to
- // DefaultPurgeableMallocZone instead of asan_zone. We might want to
- // fix this someday.
- if (orig_zone == system_purgeable_zone) {
- system_purgeable_zone->free(system_purgeable_zone, ptr);
- return;
- }
if (!FLAG_mac_ignore_invalid_free || asan_mz_size(ptr)) {
GET_STACK_TRACE_HERE_FOR_FREE(ptr);
asan_free(ptr, &stack);
More information about the llvm-commits
mailing list