summaryrefslogtreecommitdiff
path: root/runtime/quick_exception_handler.cc
diff options
context:
space:
mode:
author Santiago Aboy Solanes <solanes@google.com> 2022-10-13 12:08:36 +0100
committer Santiago Aboy Solanes <solanes@google.com> 2022-10-13 13:40:42 +0000
commit28fb3a98c57cef6e6a72e72f67d89fb63eda6223 (patch)
tree20c3ee3626f83ce5c497244466746e41fabda246 /runtime/quick_exception_handler.cc
parent9e6235f46b23fefc5c9bee4be9cc5edf2663417f (diff)
Make sure we delete the dex_pc_list vector
We were leaking memory by not destroying it before long jumping. Test: Opened the AOSP calendar app and looked for unreachable memory Bug: 251892250 Change-Id: Ib44613174cfe6e315fa77368a74db1005730ba51
Diffstat (limited to 'runtime/quick_exception_handler.cc')
-rw-r--r--runtime/quick_exception_handler.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/runtime/quick_exception_handler.cc b/runtime/quick_exception_handler.cc
index b9dd3e11b6..eb9b47180f 100644
--- a/runtime/quick_exception_handler.cc
+++ b/runtime/quick_exception_handler.cc
@@ -219,18 +219,19 @@ void QuickExceptionHandler::FindCatch(ObjPtr<mirror::Throwable> exception,
}
if (GetHandlerMethod() != nullptr) {
const DexFile* dex_file = GetHandlerMethod()->GetDexFile();
- DCHECK_GE(handler_dex_pc_list_.size(), 1u);
+ DCHECK(handler_dex_pc_list_.has_value());
+ DCHECK_GE(handler_dex_pc_list_->size(), 1u);
int line_number = annotations::GetLineNumFromPC(
- dex_file, GetHandlerMethod(), handler_dex_pc_list_.front());
+ dex_file, GetHandlerMethod(), handler_dex_pc_list_->front());
// We may have an inlined method. If so, we can add some extra logging.
std::stringstream ss;
ArtMethod* maybe_inlined_method = visitor.GetMethod();
if (maybe_inlined_method != GetHandlerMethod()) {
const DexFile* inlined_dex_file = maybe_inlined_method->GetDexFile();
- DCHECK_GE(handler_dex_pc_list_.size(), 2u);
+ DCHECK_GE(handler_dex_pc_list_->size(), 2u);
int inlined_line_number = annotations::GetLineNumFromPC(
- inlined_dex_file, maybe_inlined_method, handler_dex_pc_list_.back());
+ inlined_dex_file, maybe_inlined_method, handler_dex_pc_list_->back());
ss << " which ends up calling inlined method " << maybe_inlined_method->PrettyMethod()
<< " (line: " << inlined_line_number << ")";
}
@@ -744,10 +745,13 @@ void QuickExceptionHandler::DoLongJump(bool smash_caller_saves) {
handler_method_header_ != nullptr &&
handler_method_header_->IsNterpMethodHeader()) {
// Interpreter procceses one method at a time i.e. not inlining
- DCHECK_EQ(handler_dex_pc_list_.size(), 1u) << "We shouldn't have any inlined frames.";
+ DCHECK(handler_dex_pc_list_.has_value());
+ DCHECK_EQ(handler_dex_pc_list_->size(), 1u) << "We shouldn't have any inlined frames.";
context_->SetNterpDexPC(reinterpret_cast<uintptr_t>(
- GetHandlerMethod()->DexInstructions().Insns() + handler_dex_pc_list_.front()));
+ GetHandlerMethod()->DexInstructions().Insns() + handler_dex_pc_list_->front()));
}
+ // Clear the dex_pc list so as not to leak memory.
+ handler_dex_pc_list_.reset();
context_->DoLongJump();
UNREACHABLE();
}