Fix DCHECK when freeing last obj from free-list large-object space
Bug: 160737021
Test: art/test/testrunner/testrunner.py --target -t 659-unpadded-array
Change-Id: I363bc98709a8523c8a33aaa5f0bb7f8e218d0d1f
diff --git a/runtime/gc/space/large_object_space.cc b/runtime/gc/space/large_object_space.cc
index 2d17a18..f1df45f 100644
--- a/runtime/gc/space/large_object_space.cc
+++ b/runtime/gc/space/large_object_space.cc
@@ -336,7 +336,7 @@
size_t FreeListSpace::GetSlotIndexForAllocationInfo(const AllocationInfo* info) const {
DCHECK_GE(info, allocation_info_);
- DCHECK_LT(info, reinterpret_cast<AllocationInfo*>(allocation_info_map_.End()));
+ DCHECK_LE(info, reinterpret_cast<AllocationInfo*>(allocation_info_map_.End()));
return info - allocation_info_;
}
@@ -457,6 +457,10 @@
// The previous allocation info must not be free since we are supposed to always coalesce.
DCHECK_EQ(info->GetPrevFreeBytes(), 0U) << "Previous allocation was free";
}
+ // NOTE: next_info could be pointing right after the allocation_info_map_
+ // when freeing object in the very end of the space. But that's safe
+ // as we don't dereference it in that case. We only use it to calculate
+ // next_addr using offset within the map.
uintptr_t next_addr = GetAddressForAllocationInfo(next_info);
if (next_addr >= free_end_start) {
// Easy case, the next chunk is the end free region.