summaryrefslogtreecommitdiffstats
path: root/runtime/class_linker.cc
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2016-05-10 18:13:20 -0700
committerMathieu Chartier <mathieuc@google.com>2016-05-11 14:05:03 -0700
commit92091bde26fb9fc54b7e5f459b696d4b88ea30de (patch)
tree21bc4b8ff193efa3574bed7c6629ec6102b560c4 /runtime/class_linker.cc
parentab249381b4757e96da31c0cdcaf889861d1cc928 (diff)
downloadandroid_art-92091bde26fb9fc54b7e5f459b696d4b88ea30de.tar.gz
android_art-92091bde26fb9fc54b7e5f459b696d4b88ea30de.tar.bz2
android_art-92091bde26fb9fc54b7e5f459b696d4b88ea30de.zip
Prevent ArtMethod clearing race
There was race condition where the GC would be visiting the methods of a class while the class linker overwrote the contents with 0xFE when copying to a new array. Since the GC is holding the class table lock at this time, we can use this lock in the class linker to prevent the race. Bug: 28699001 (cherry picked from commit 10c5f56423feaf3eadb3d4c09c61d2b998404162) Change-Id: I5ddca93106cb8e48962cf44e5ce434c45e05cd0c
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r--runtime/class_linker.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index e7a560b398..94872ba481 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -6968,6 +6968,7 @@ bool ClassLinker::LinkInterfaceMethods(
}
// Put some random garbage in old methods to help find stale pointers.
if (methods != old_methods && old_methods != nullptr) {
+ WriterMutexLock mu(self, ClassTableForClassLoader(klass->GetClassLoader())->GetLock());
memset(old_methods, 0xFEu, old_size);
}
} else {