diff options
author | Mathieu Chartier <mathieuc@google.com> | 2014-01-09 11:23:53 -0800 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2014-03-05 12:44:22 -0800 |
commit | 661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8 (patch) | |
tree | 02e428694277d85a98505f8e814aba378fc7651c /runtime/gc/space/valgrind_malloc_space-inl.h | |
parent | 3cd52df3d740f8a656233b199dfcaab165f415ff (diff) | |
download | android_art-661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8.tar.gz android_art-661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8.tar.bz2 android_art-661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8.zip |
Fix valgrind gtests and memory leaks.
All tests pass other than image_test which passes if some bad reads
are disabled (buzbee working on this).
Change-Id: Ifd6b6e3aed0bc867703b6e818353a9f296609422
Diffstat (limited to 'runtime/gc/space/valgrind_malloc_space-inl.h')
-rw-r--r-- | runtime/gc/space/valgrind_malloc_space-inl.h | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/runtime/gc/space/valgrind_malloc_space-inl.h b/runtime/gc/space/valgrind_malloc_space-inl.h index 4b0c8e3548..ed97e60b2e 100644 --- a/runtime/gc/space/valgrind_malloc_space-inl.h +++ b/runtime/gc/space/valgrind_malloc_space-inl.h @@ -38,9 +38,6 @@ mirror::Object* ValgrindMallocSpace<S, A>::AllocWithGrowth(Thread* self, size_t if (obj_with_rdz == nullptr) { return nullptr; } - if (usable_size != nullptr) { - *usable_size -= 2 * kValgrindRedZoneBytes; - } mirror::Object* result = reinterpret_cast<mirror::Object*>( reinterpret_cast<byte*>(obj_with_rdz) + kValgrindRedZoneBytes); // Make redzones as no access. @@ -58,9 +55,6 @@ mirror::Object* ValgrindMallocSpace<S, A>::Alloc(Thread* self, size_t num_bytes, if (obj_with_rdz == nullptr) { return nullptr; } - if (usable_size != nullptr) { - *usable_size -= 2 * kValgrindRedZoneBytes; - } mirror::Object* result = reinterpret_cast<mirror::Object*>( reinterpret_cast<byte*>(obj_with_rdz) + kValgrindRedZoneBytes); // Make redzones as no access. @@ -73,10 +67,7 @@ template <typename S, typename A> size_t ValgrindMallocSpace<S, A>::AllocationSize(mirror::Object* obj, size_t* usable_size) { size_t result = S::AllocationSize(reinterpret_cast<mirror::Object*>( reinterpret_cast<byte*>(obj) - kValgrindRedZoneBytes), usable_size); - if (usable_size != nullptr) { - *usable_size -= 2 * kValgrindRedZoneBytes; - } - return result - 2 * kValgrindRedZoneBytes; + return result; } template <typename S, typename A> @@ -84,11 +75,10 @@ size_t ValgrindMallocSpace<S, A>::Free(Thread* self, mirror::Object* ptr) { void* obj_after_rdz = reinterpret_cast<void*>(ptr); void* obj_with_rdz = reinterpret_cast<byte*>(obj_after_rdz) - kValgrindRedZoneBytes; // Make redzones undefined. - size_t allocation_size = - AllocationSize(reinterpret_cast<mirror::Object*>(obj_with_rdz), nullptr); - VALGRIND_MAKE_MEM_UNDEFINED(obj_with_rdz, allocation_size); - size_t freed = S::Free(self, reinterpret_cast<mirror::Object*>(obj_with_rdz)); - return freed - 2 * kValgrindRedZoneBytes; + size_t usable_size = 0; + AllocationSize(ptr, &usable_size); + VALGRIND_MAKE_MEM_UNDEFINED(obj_with_rdz, usable_size); + return S::Free(self, reinterpret_cast<mirror::Object*>(obj_with_rdz)); } template <typename S, typename A> @@ -96,6 +86,7 @@ size_t ValgrindMallocSpace<S, A>::FreeList(Thread* self, size_t num_ptrs, mirror size_t freed = 0; for (size_t i = 0; i < num_ptrs; i++) { freed += Free(self, ptrs[i]); + ptrs[i] = nullptr; } return freed; } |