Possible previous bug:
Allocation fails due to OOM and the collector transitions.
This caused us to incorrectly retry the allocation with a pending
exception. We now return null if there is a pending exception.
Bug:
17164348
Change-Id: I22eab472afb2fdea6e800963ccb35ec0755ba0e6
&klass);
if (obj == nullptr) {
bool after_is_current_allocator = allocator == GetCurrentAllocator();
- if (is_current_allocator && !after_is_current_allocator) {
+ // If there is a pending exception, fail the allocation right away since the next one
+ // could cause OOM and abort the runtime.
+ if (!self->IsExceptionPending() && is_current_allocator && !after_is_current_allocator) {
// If the allocator changed, we need to restart the allocation.
return AllocObject<kInstrumented>(self, klass, byte_count, pre_fence_visitor);
}