Fix a moving gc bug in Instrumentation::ExceptionCaughtEvent.
This fixes JDWP exception caught test crashes.
Bug: 34929692
Test: CtsJdwpTestCases on angler.
Test: test-art-host
Test: The jdwp test on host.
Change-Id: I2f6a66d7e871e6c7d65a8ad287249286b301c3b1
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc
index f11e2cb..d862ff2 100644
--- a/runtime/instrumentation.cc
+++ b/runtime/instrumentation.cc
@@ -1010,15 +1010,18 @@
void Instrumentation::ExceptionCaughtEvent(Thread* thread,
mirror::Throwable* exception_object) const {
+ Thread* self = Thread::Current();
+ StackHandleScope<1> hs(self);
+ Handle<mirror::Throwable> h_exception(hs.NewHandle(exception_object));
if (HasExceptionCaughtListeners()) {
- DCHECK_EQ(thread->GetException(), exception_object);
+ DCHECK_EQ(thread->GetException(), h_exception.Get());
thread->ClearException();
for (InstrumentationListener* listener : exception_caught_listeners_) {
if (listener != nullptr) {
- listener->ExceptionCaught(thread, exception_object);
+ listener->ExceptionCaught(thread, h_exception.Get());
}
}
- thread->SetException(exception_object);
+ thread->SetException(h_exception.Get());
}
}