summaryrefslogtreecommitdiffstats
path: root/runtime/mirror
diff options
context:
space:
mode:
authorPavel Vyssotski <pavel.n.vyssotski@intel.com>2014-12-02 19:54:50 +0600
committerPavel Vyssotski <pavel.n.vyssotski@intel.com>2014-12-02 20:53:17 +0600
commit3ac90da48e9cd56eb4b392c7f176e9267d146500 (patch)
treef2ef3b42669aa52130e19b3709afc3239998fdeb /runtime/mirror
parent98646a3d98075da05f9959b2cecea849183dbd27 (diff)
downloadart-3ac90da48e9cd56eb4b392c7f176e9267d146500.tar.gz
art-3ac90da48e9cd56eb4b392c7f176e9267d146500.tar.bz2
art-3ac90da48e9cd56eb4b392c7f176e9267d146500.zip
Fix OOM throwing if it happens in finalizer reference (take 2)
The Class::Alloc should return null if OOM happened during adding finalizer reference, even if finalizable object is allocated succesfully. Added new more reliable test. Change-Id: Id5fed3bdb16297d6d3a2b14ce62cc305aa703d60 Signed-off-by: Dmitry Petrochenko <dmitry.petrochenko@intel.com> Signed-off-by: Serguei Katkov <serguei.i.katkov@intel.com> Signed-off-by: Pavel Vyssotski <pavel.n.vyssotski@intel.com>
Diffstat (limited to 'runtime/mirror')
-rw-r--r--runtime/mirror/class-inl.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index 599f178cbf..1662ebfe82 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -575,6 +575,10 @@ inline Object* Class::Alloc(Thread* self, gc::AllocatorType allocator_type) {
allocator_type, VoidFunctor());
if (add_finalizer && LIKELY(obj != nullptr)) {
heap->AddFinalizerReference(self, &obj);
+ if (UNLIKELY(self->IsExceptionPending())) {
+ // Failed to allocate finalizer reference, it means that the whole allocation failed.
+ obj = nullptr;
+ }
}
return obj;
}