OSDN Git Service

Check that classes are resolved in GetMethodsVisitor
authorMathieu Chartier <mathieuc@google.com>
Wed, 21 Jun 2017 18:48:15 +0000 (11:48 -0700)
committerMathieu Chartier <mathieuc@google.com>
Wed, 21 Jun 2017 21:05:24 +0000 (21:05 +0000)
VisitClasses doesn't internally check that classes are resolved. This
caused GetClassesAndMethodsVisitor to occasionally see ArtMethods
that didn't have their declaring class filled in.

The fix is to check that the class is actually resolved.

(cherry picked from commit 4219814f1545db945c1bacf4d38221371993a72d)

Test: test-art-host
Bug: 62585606

Merged-In: I3ed647ae15900c96d2180eb5c799f45393794dda
Change-Id: Id09e9e27cf09a921fbce4c917b8b6ef2daeaabaa

runtime/jit/profile_saver.cc

index 166b6f4..f3a913e 100644 (file)
@@ -188,7 +188,9 @@ class GetMethodsVisitor : public ClassVisitor {
       startup_method_samples_(startup_method_samples) {}
 
   virtual bool operator()(ObjPtr<mirror::Class> klass) REQUIRES_SHARED(Locks::mutator_lock_) {
-    if (Runtime::Current()->GetHeap()->ObjectIsInBootImageSpace(klass)) {
+    if (Runtime::Current()->GetHeap()->ObjectIsInBootImageSpace(klass) ||
+        !klass->IsResolved() ||
+        klass->IsErroneousResolved()) {
       return true;
     }
     for (ArtMethod& method : klass->GetMethods(kRuntimePointerSize)) {