summaryrefslogtreecommitdiffstats
path: root/runtime/gc
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2015-04-19 13:36:11 -0700
committerMathieu Chartier <mathieuc@google.com>2015-04-19 15:26:57 -0700
commitc8980deb1c5325a23dc7463ab2b79b2795f3103f (patch)
tree068af2c84f54f71b278aa7d0592786394a8f8f47 /runtime/gc
parentf5091eee4abe73c64959e53bda684bd689569643 (diff)
downloadart-c8980deb1c5325a23dc7463ab2b79b2795f3103f.zip
art-c8980deb1c5325a23dc7463ab2b79b2795f3103f.tar.gz
art-c8980deb1c5325a23dc7463ab2b79b2795f3103f.tar.bz2
Add sanity check for large object allocation
If there is a large object which ends up being covered by a space bitmap, it will not be marked correctly by the GC. Change-Id: Icdd0aaa207f476dd08effcee6cfbbb5de7ca1d17
Diffstat (limited to 'runtime/gc')
-rw-r--r--runtime/gc/space/large_object_space.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/runtime/gc/space/large_object_space.cc b/runtime/gc/space/large_object_space.cc
index a4a9d80..7353c83 100644
--- a/runtime/gc/space/large_object_space.cc
+++ b/runtime/gc/space/large_object_space.cc
@@ -18,6 +18,7 @@
#include <memory>
+#include "gc/accounting/heap_bitmap-inl.h"
#include "gc/accounting/space_bitmap-inl.h"
#include "base/logging.h"
#include "base/mutex-inl.h"
@@ -127,8 +128,18 @@ mirror::Object* LargeObjectMapSpace::Alloc(Thread* self, size_t num_bytes,
LOG(WARNING) << "Large object allocation failed: " << error_msg;
return NULL;
}
+ mirror::Object* const obj = reinterpret_cast<mirror::Object*>(mem_map->Begin());
+ if (kIsDebugBuild) {
+ ReaderMutexLock mu2(Thread::Current(), *Locks::heap_bitmap_lock_);
+ auto* heap = Runtime::Current()->GetHeap();
+ auto* live_bitmap = heap->GetLiveBitmap();
+ auto* space_bitmap = live_bitmap->GetContinuousSpaceBitmap(obj);
+ CHECK(space_bitmap == nullptr) << obj << " overlaps with bitmap " << *space_bitmap;
+ auto* obj_end = reinterpret_cast<mirror::Object*>(mem_map->End());
+ space_bitmap = live_bitmap->GetContinuousSpaceBitmap(obj_end - 1);
+ CHECK(space_bitmap == nullptr) << obj_end << " overlaps with bitmap " << *space_bitmap;
+ }
MutexLock mu(self, lock_);
- mirror::Object* obj = reinterpret_cast<mirror::Object*>(mem_map->Begin());
large_objects_.push_back(obj);
mem_maps_.Put(obj, mem_map);
const size_t allocation_size = mem_map->BaseSize();