Fix moving GC bug in cloning finalizable objects
It is not safe to have thread suspension in the PreFenceVisitor. The fix is
to add the finalizer reference in the caller.
Test: art/tools/run-libcore-tests.sh '--mode=host' '--variant=X32' --debug
Bug: 31113334
Change-Id: I1e4650f8b75408a3d07e2c51ac334ff98552cfb5
diff --git a/runtime/mirror/object.h b/runtime/mirror/object.h
index 175b0c3..84aa96c 100644
--- a/runtime/mirror/object.h
+++ b/runtime/mirror/object.h
@@ -609,11 +609,10 @@
}
}
- // A utility function that copies an object in a read barrier and
- // write barrier-aware way. This is internally used by Clone() and
- // Class::CopyOf().
- static Object* CopyObject(Thread* self,
- ObjPtr<mirror::Object> dest,
+ // A utility function that copies an object in a read barrier and write barrier-aware way.
+ // This is internally used by Clone() and Class::CopyOf(). If the object is finalizable,
+ // it is the callers job to call Heap::AddFinalizerReference.
+ static Object* CopyObject(ObjPtr<mirror::Object> dest,
ObjPtr<mirror::Object> src,
size_t num_bytes)
REQUIRES_SHARED(Locks::mutator_lock_);