summaryrefslogtreecommitdiffstats
path: root/runtime/monitor.cc
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2014-07-17 18:52:42 -0700
committerIan Rogers <irogers@google.com>2014-07-17 18:59:40 -0700
commitf3d874c60ee3ada19ce26a5c4e532312b6f3a9e9 (patch)
treede14ab8b610f43a2c2c4c02f4ac67d614919fde2 /runtime/monitor.cc
parent031ddea20cb311dfdb3bd16a13750f9cb426b299 (diff)
downloadart-f3d874c60ee3ada19ce26a5c4e532312b6f3a9e9.tar.gz
art-f3d874c60ee3ada19ce26a5c4e532312b6f3a9e9.tar.bz2
art-f3d874c60ee3ada19ce26a5c4e532312b6f3a9e9.zip
Avoid race in single thread suspension.
Don't allow more than one concurrent single thread suspension to avoid potential cycles and deadlocks where threads try to suspend each other. Bug: 16364458, 16354227 Change-Id: I907f1d5591a6aa5c241d37d6b4a34f968f98df77
Diffstat (limited to 'runtime/monitor.cc')
-rw-r--r--runtime/monitor.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/runtime/monitor.cc b/runtime/monitor.cc
index 4b26edac61..b33b286f8b 100644
--- a/runtime/monitor.cc
+++ b/runtime/monitor.cc
@@ -680,6 +680,8 @@ void Monitor::InflateThinLocked(Thread* self, Handle<mirror::Object> obj, LockWo
Thread* owner;
{
ScopedThreadStateChange tsc(self, kBlocked);
+ // Take suspend thread lock to avoid races with threads trying to suspend this one.
+ MutexLock mu(self, *Locks::thread_list_suspend_thread_lock_);
owner = thread_list->SuspendThreadByThreadId(owner_thread_id, false, &timed_out);
}
if (owner != nullptr) {