diff --git a/runtime/vm/compiler/frontend/bytecode_reader.cc b/runtime/vm/compiler/frontend/bytecode_reader.cc index 55a09c56900..870a42ec9ef 100644 --- a/runtime/vm/compiler/frontend/bytecode_reader.cc +++ b/runtime/vm/compiler/frontend/bytecode_reader.cc @@ -945,7 +945,7 @@ void BytecodeReaderHelper::ReadExceptionsTable(const Bytecode& bytecode, if (try_block_count > 0) { const ObjectPool& pool = ObjectPool::Handle(Z, bytecode.object_pool()); AbstractType& handler_type = AbstractType::Handle(Z); - Array& handler_types = Array::ZoneHandle(Z); + Array& handler_types = Array::Handle(Z); DescriptorList* pc_descriptors_list = new (Z) DescriptorList(64); ExceptionHandlerList* exception_handlers_list = new (Z) ExceptionHandlerList(); @@ -986,9 +986,13 @@ void BytecodeReaderHelper::ReadExceptionsTable(const Bytecode& bytecode, DeoptId::kNone, TokenPosition::kNoSource, -1); + // The exception handler keeps a zone handle of the types array, rather + // than a raw pointer. Do not share the handle across iterations to avoid + // clobbering the array. exception_handlers_list->AddHandler( try_index, outer_try_index, handler_pc, TokenPosition::kNoSource, - is_generated, handler_types, needs_stacktrace); + is_generated, Array::ZoneHandle(Z, handler_types.raw()), + needs_stacktrace); } const PcDescriptors& descriptors = PcDescriptors::Handle( Z, pc_descriptors_list->FinalizePcDescriptors(bytecode.PayloadStart())); diff --git a/runtime/vm/debugger.cc b/runtime/vm/debugger.cc index 4be812facd1..0dd231a64ce 100644 --- a/runtime/vm/debugger.cc +++ b/runtime/vm/debugger.cc @@ -1184,6 +1184,10 @@ ActivationFrame* DebuggerStackTrace::GetHandlerFrame( const Instance& exc_obj) const { for (intptr_t frame_index = 0; frame_index < Length(); frame_index++) { ActivationFrame* frame = FrameAt(frame_index); + if (FLAG_trace_debugger_stacktrace) { + OS::PrintErr("GetHandlerFrame: #%04" Pd " %s", frame_index, + frame->ToCString()); + } if (frame->HandlesException(exc_obj)) { return frame; } @@ -1606,6 +1610,10 @@ RawTypeArguments* ActivationFrame::BuildParameters( } const char* ActivationFrame::ToCString() { + if (function().IsNull()) { + return Thread::Current()->zone()->PrintToString("[ Frame kind: %s]\n", + KindToCString(kind_)); + } const String& url = String::Handle(SourceUrl()); intptr_t line = LineNumber(); const char* func_name = Debugger::QualifiedFunctionName(function()); @@ -1630,7 +1638,7 @@ const char* ActivationFrame::ToCString() { "\turl = %s\n" "\tline = %" Pd "\n" - "\tcontext = %s\n", + "\tcontext = %s]\n", IsInterpreted() ? "bytecode" : "code", func_name, url.ToCString(), line, ctx_.ToCString()); } diff --git a/runtime/vm/stack_trace.cc b/runtime/vm/stack_trace.cc index b21b28e2cfd..17724a3b5d0 100644 --- a/runtime/vm/stack_trace.cc +++ b/runtime/vm/stack_trace.cc @@ -85,7 +85,6 @@ intptr_t StackTraceUtils::CollectFrames(Thread* thread, code_array.SetAt(array_offset, bytecode); } else { code = frame->LookupDartCode(); - function = code.function(); offset = Smi::New(frame->pc() - code.PayloadStart()); code_array.SetAt(array_offset, code); }