summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author Ian Rogers <irogers@google.com> 2012-01-12 18:14:32 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2012-01-12 18:14:32 -0800
commit4004b36bf6dfae095092ed4579c5ad6e4198fc30 (patch)
treeac0750968981ad5cf7449ddcc7c1b39e847d054c /src
parentd9c37b307713572b6ea32e9f6ff965d15b3f4b88 (diff)
parent672f520b125639c090cc38c9ae7231e0dfbd31dd (diff)
Merge "Fix race in double verifying super class" into dalvik-dev
Diffstat (limited to 'src')
-rw-r--r--src/class_linker.cc30
-rw-r--r--src/dex_verifier.cc3
-rw-r--r--src/object_utils.h30
3 files changed, 33 insertions, 30 deletions
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 8c46a7e403..4226ea5bb6 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -23,7 +23,6 @@
#include "intern_table.h"
#include "leb128.h"
#include "logging.h"
-#include "monitor.h"
#include "oat_file.h"
#include "object.h"
#include "object_utils.h"
@@ -193,35 +192,6 @@ const char* ClassLinker::class_roots_descriptors_[] = {
"[Ljava/lang/StackTraceElement;",
};
-class ObjectLock {
- public:
- explicit ObjectLock(Object* object) : self_(Thread::Current()), obj_(object) {
- CHECK(object != NULL);
- obj_->MonitorEnter(self_);
- }
-
- ~ObjectLock() {
- obj_->MonitorExit(self_);
- }
-
- void Wait() {
- return Monitor::Wait(self_, obj_, 0, 0, false);
- }
-
- void Notify() {
- obj_->Notify();
- }
-
- void NotifyAll() {
- obj_->NotifyAll();
- }
-
- private:
- Thread* self_;
- Object* obj_;
- DISALLOW_COPY_AND_ASSIGN(ObjectLock);
-};
-
ClassLinker* ClassLinker::Create(const std::string& boot_class_path, InternTable* intern_table) {
CHECK_NE(boot_class_path.size(), 0U);
UniquePtr<ClassLinker> class_linker(new ClassLinker(intern_table));
diff --git a/src/dex_verifier.cc b/src/dex_verifier.cc
index 25fadb0c91..117218657b 100644
--- a/src/dex_verifier.cc
+++ b/src/dex_verifier.cc
@@ -900,6 +900,9 @@ bool DexVerifier::VerifyClass(const Class* klass) {
return false;
}
if (super != NULL) {
+ // Acquire lock to prevent races on verifying the super class
+ ObjectLock lock(super);
+
if (!super->IsVerified() && !super->IsErroneous()) {
Runtime::Current()->GetClassLinker()->VerifyClass(super);
}
diff --git a/src/object_utils.h b/src/object_utils.h
index f9aca10e65..0412858084 100644
--- a/src/object_utils.h
+++ b/src/object_utils.h
@@ -21,6 +21,7 @@
#include "dex_cache.h"
#include "dex_file.h"
#include "intern_table.h"
+#include "monitor.h"
#include "object.h"
#include "runtime.h"
#include "UniquePtr.h"
@@ -29,6 +30,35 @@
namespace art {
+class ObjectLock {
+ public:
+ explicit ObjectLock(Object* object) : self_(Thread::Current()), obj_(object) {
+ CHECK(object != NULL);
+ obj_->MonitorEnter(self_);
+ }
+
+ ~ObjectLock() {
+ obj_->MonitorExit(self_);
+ }
+
+ void Wait() {
+ return Monitor::Wait(self_, obj_, 0, 0, false);
+ }
+
+ void Notify() {
+ obj_->Notify();
+ }
+
+ void NotifyAll() {
+ obj_->NotifyAll();
+ }
+
+ private:
+ Thread* self_;
+ Object* obj_;
+ DISALLOW_COPY_AND_ASSIGN(ObjectLock);
+};
+
class ClassHelper {
public:
ClassHelper(const Class* c = NULL, ClassLinker* l = NULL)