From 3481f7a104723480497e65d2c3beee67de3c4760 Mon Sep 17 00:00:00 2001 From: Hiroshi Yamauchi Date: Fri, 10 Feb 2017 12:07:36 -0800 Subject: [PATCH] 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 --- runtime/instrumentation.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc index f11e2cba1..d862ff270 100644 --- a/runtime/instrumentation.cc +++ b/runtime/instrumentation.cc @@ -1010,15 +1010,18 @@ void Instrumentation::FieldWriteEventImpl(Thread* thread, mirror::Object* this_o void Instrumentation::ExceptionCaughtEvent(Thread* thread, mirror::Throwable* exception_object) const { + Thread* self = Thread::Current(); + StackHandleScope<1> hs(self); + Handle 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()); } } -- 2.11.0