summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Hertz <shertz@google.com>2014-04-01 15:31:05 +0200
committerSebastien Hertz <shertz@google.com>2014-04-04 11:11:05 +0200
commitbf079fe015e3b2d966e111efc61728b6e6892ec3 (patch)
tree43b61e0b303090830f0d6067c56f2ded18b2ca9d
parent6f31ce382777d82952d019908866ff28ef3bbc76 (diff)
downloadart-bf079fe015e3b2d966e111efc61728b6e6892ec3.tar.gz
art-bf079fe015e3b2d966e111efc61728b6e6892ec3.tar.bz2
art-bf079fe015e3b2d966e111efc61728b6e6892ec3.zip
Fix crash when debugging exception
Fixes a crash when detaching the debugger during an exception event. The cause is a concurrent modification of Instrumentation::exception_caught_listeners_ list (consequence of debugger being detached) while we loop over its elements. Workaround the issue by making a copy of the listeners list. Bug: 13738672 Change-Id: I56b84c5c8f31d6fbda1ba7cb35caeefc5e7ca60f
-rw-r--r--runtime/instrumentation.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc
index 525e2b30df..c798fbf6e0 100644
--- a/runtime/instrumentation.cc
+++ b/runtime/instrumentation.cc
@@ -750,7 +750,10 @@ void Instrumentation::ExceptionCaughtEvent(Thread* thread, const ThrowLocation&
if (have_exception_caught_listeners_) {
DCHECK_EQ(thread->GetException(NULL), exception_object);
thread->ClearException();
- for (InstrumentationListener* listener : exception_caught_listeners_) {
+ // TODO: The copy below is due to the debug listener having an action where it can remove
+ // itself as a listener and break the iterator. The copy only works around the problem.
+ std::list<InstrumentationListener*> copy(exception_caught_listeners_);
+ for (InstrumentationListener* listener : copy) {
listener->ExceptionCaught(thread, throw_location, catch_method, catch_dex_pc, exception_object);
}
thread->SetException(throw_location, exception_object);