diff options
author | Andreas Gampe <agampe@google.com> | 2015-10-08 19:34:15 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-10-08 19:34:15 +0000 |
commit | 1c2f38b9795138b4afb6736003558a989e433b03 (patch) | |
tree | bb3d2fc3c140999a8d876ceda6154a2857ddaeeb | |
parent | ebaef4c5ee3c7cbf92ace656c5a935bc1daaaf1f (diff) | |
parent | a13d2e118700975d2cda73ffff85546a387308db (diff) | |
download | art-1c2f38b9795138b4afb6736003558a989e433b03.tar.gz art-1c2f38b9795138b4afb6736003558a989e433b03.tar.bz2 art-1c2f38b9795138b4afb6736003558a989e433b03.zip |
am a13d2e11: Merge "ART: Do not abort on exception in CreatePeer" into mnc-dr-dev
* commit 'a13d2e118700975d2cda73ffff85546a387308db':
ART: Do not abort on exception in CreatePeer
-rw-r--r-- | runtime/thread.cc | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/runtime/thread.cc b/runtime/thread.cc index 5274f9e0d3..6e8f89cb49 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -546,6 +546,18 @@ Thread* Thread::Attach(const char* thread_name, bool as_daemon, jobject thread_g // a native peer! if (create_peer) { self->CreatePeer(thread_name, as_daemon, thread_group); + if (self->IsExceptionPending()) { + // We cannot keep the exception around, as we're deleting self. Try to be helpful and log it. + { + ScopedObjectAccess soa(self); + LOG(ERROR) << "Exception creating thread peer:"; + LOG(ERROR) << self->GetException()->Dump(); + self->ClearException(); + } + runtime->GetThreadList()->Unregister(self); + // Unregister deletes self, no need to do this here. + return nullptr; + } } else { // These aren't necessary, but they improve diagnostics for unit tests & command-line tools. if (thread_name != nullptr) { @@ -594,7 +606,9 @@ void Thread::CreatePeer(const char* name, bool as_daemon, jobject thread_group) WellKnownClasses::java_lang_Thread, WellKnownClasses::java_lang_Thread_init, thread_group, thread_name.get(), thread_priority, thread_is_daemon); - AssertNoPendingException(); + if (IsExceptionPending()) { + return; + } Thread* self = this; DCHECK_EQ(self, Thread::Current()); @@ -1256,6 +1270,7 @@ void Thread::FinishStartup() { // Finish attaching the main thread. ScopedObjectAccess soa(Thread::Current()); Thread::Current()->CreatePeer("main", false, runtime->GetMainThreadGroup()); + Thread::Current()->AssertNoPendingException(); Runtime::Current()->GetClassLinker()->RunRootClinits(); } |