From 8a243118dbd3ee751ae7e3d6827469895490a377 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Thu, 14 Nov 2019 17:33:12 -0800 Subject: [PATCH] unwindstack: fix dangling pointer in LocalUpdatableMaps. Previously, when reparsing /proc/self/maps, we would remove duplicate MapInfo entries, but leave the following entry's prev_map pointing toward the soon-to-be-deleted MapInfo, leading to explosions. Test: libunwindstack_test Test: booted with libfdtrack.so preloaded Change-Id: Ibfb7a8712540fe3aaadc10e9c31938f6ecddf17b --- libunwindstack/Maps.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libunwindstack/Maps.cpp b/libunwindstack/Maps.cpp index 250e600bc..0ab68dbb5 100644 --- a/libunwindstack/Maps.cpp +++ b/libunwindstack/Maps.cpp @@ -139,6 +139,9 @@ bool LocalUpdatableMaps::Reparse() { if (start == info->start && end == info->end && flags == info->flags && *name == info->name) { // No need to check search_map_idx = old_map_idx + 1; + if (new_map_idx + 1 < maps_.size()) { + maps_[new_map_idx + 1]->prev_map = info.get(); + } maps_[new_map_idx] = nullptr; total_entries--; break;