diff options
author | Mathieu Chartier <mathieuc@google.com> | 2015-01-09 09:46:49 -0800 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2015-01-09 10:01:41 -0800 |
commit | bef89c910dc40f7e82ee56c3c8e8fdaa0cd5562b (patch) | |
tree | 42a5a28ce6c8f3a0f51067397f989a0be457ec6c | |
parent | 46af48acf4221a7f819d58dfffb576d0523ae285 (diff) | |
download | art-bef89c910dc40f7e82ee56c3c8e8fdaa0cd5562b.zip art-bef89c910dc40f7e82ee56c3c8e8fdaa0cd5562b.tar.gz art-bef89c910dc40f7e82ee56c3c8e8fdaa0cd5562b.tar.bz2 |
Fix HandleScope with wrong thread error
Possibly fixes
+art F 5127 6995 art/runtime/handle_scope-inl.h:43]
Check failed: top_handle_scope == this
(top_handle_scope=0x2b449293c770, this=0x2b4492d6a0a8)
Seen in tests. A possible cause was that the thread dumping stacks
was running checkpoints on a suspended thread but putting a
HandleScope on that thread instead of itself. This isn't safe if the
suspended thread is doing HandleScope stuff in a non runnable state.
Change-Id: Icdaadabca5aff8d380d5cc9570b9e899fe790a62
-rw-r--r-- | runtime/handle_scope-inl.h | 1 | ||||
-rw-r--r-- | runtime/thread.cc | 5 |
2 files changed, 4 insertions, 2 deletions
diff --git a/runtime/handle_scope-inl.h b/runtime/handle_scope-inl.h index 421a413..222083b 100644 --- a/runtime/handle_scope-inl.h +++ b/runtime/handle_scope-inl.h @@ -28,6 +28,7 @@ namespace art { template<size_t kNumReferences> inline StackHandleScope<kNumReferences>::StackHandleScope(Thread* self, mirror::Object* fill_value) : HandleScope(self->GetTopHandleScope(), kNumReferences), self_(self), pos_(0) { + DCHECK_EQ(self, Thread::Current()); static_assert(kNumReferences >= 1, "StackHandleScope must contain at least 1 reference"); // TODO: Figure out how to use a compile assert. CHECK_EQ(&storage_[0], GetReferences()); diff --git a/runtime/thread.cc b/runtime/thread.cc index d2d5be7..527d758 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -982,8 +982,9 @@ static bool ShouldShowNativeStack(const Thread* thread) void Thread::DumpJavaStack(std::ostream& os) const { // Dumping the Java stack involves the verifier for locks. The verifier operates under the // assumption that there is no exception pending on entry. Thus, stash any pending exception. - // TODO: Find a way to avoid const_cast. - StackHandleScope<3> scope(const_cast<Thread*>(this)); + // Thread::Current() instead of this in case a thread is dumping the stack of another suspended + // thread. + StackHandleScope<3> scope(Thread::Current()); Handle<mirror::Throwable> exc; Handle<mirror::Object> throw_location_this_object; Handle<mirror::ArtMethod> throw_location_method; |