Correctly use handles for JVMTI heap iteration.
We were incorrectly using an ObjPtr to store the filter-class in
IterateThroughHeap and FollowReferences. This could cause issues if GC
was occurring during the early parts of the call. Fix this issues by
properly handlerizing the pointer.
Test: ./test.py --host
Bug: 161574896
Change-Id: I2ed8e3e4b7af8fded69e8d86adf2049e907289e8
diff --git a/openjdkjvmti/ti_heap.cc b/openjdkjvmti/ti_heap.cc
index 905ed95..f4e34dd 100644
--- a/openjdkjvmti/ti_heap.cc
+++ b/openjdkjvmti/ti_heap.cc
@@ -759,7 +759,8 @@
bool stop_reports = false;
const HeapFilter heap_filter(heap_filter_int);
- art::ObjPtr<art::mirror::Class> filter_klass = soa.Decode<art::mirror::Class>(klass);
+ art::StackHandleScope<1> hs(self);
+ art::Handle<art::mirror::Class> filter_klass(hs.NewHandle(soa.Decode<art::mirror::Class>(klass)));
auto visitor = [&](art::mirror::Object* obj) REQUIRES_SHARED(art::Locks::mutator_lock_) {
// Early return, as we can't really stop visiting.
if (stop_reports) {
@@ -781,7 +782,7 @@
}
if (filter_klass != nullptr) {
- if (filter_klass != klass) {
+ if (filter_klass.Get() != klass) {
return;
}
}