Check that dex pc is in a valid map.
Add new unit tests for dex pc being non-zero.
Bug: 73004673
Test: Ran unit tests.
Test: Ran art 137-cfi test on host for interpreter.
Change-Id: I09bbf96d0ed65fc1e5896e4ab2bc67867e3b7fdb
diff --git a/libunwindstack/Unwinder.cpp b/libunwindstack/Unwinder.cpp
index 6119ee0..644bfa8 100644
--- a/libunwindstack/Unwinder.cpp
+++ b/libunwindstack/Unwinder.cpp
@@ -54,13 +54,18 @@
frame->sp = regs_->sp();
MapInfo* info = maps_->Find(dex_pc);
- frame->map_start = info->start;
- frame->map_end = info->end;
- frame->map_offset = info->offset;
- frame->map_load_bias = info->load_bias;
- frame->map_flags = info->flags;
- frame->map_name = info->name;
- frame->rel_pc = dex_pc - info->start;
+ if (info != nullptr) {
+ frame->map_start = info->start;
+ frame->map_end = info->end;
+ frame->map_offset = info->offset;
+ frame->map_load_bias = info->load_bias;
+ frame->map_flags = info->flags;
+ frame->map_name = info->name;
+ frame->rel_pc = dex_pc - info->start;
+ } else {
+ frame->rel_pc = dex_pc;
+ return;
+ }
#if !defined(NO_LIBDEXFILE_SUPPORT)
if (dex_files_ == nullptr) {