aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2016-12-02 10:22:45 -0800
committerChristopher Ferris <cferris@google.com>2016-12-05 07:54:14 -0800
commitf7eef920b5a22f5e1635ed61c703b6400758436a (patch)
treef201eba89c88f8bcdc0a178d51c99d374da45990
parentd35224ff189bf5fed77bfcc36c790c8dd205d0e0 (diff)
downloadlibunwind-nougat-mr2.1-release.tar.gz
The struct unw_addr_space is very large (at least 13624 bytes on arm), but is on the stack in the function map_create_list. Allocate this function when needed instead of putting it on the stack. Bug: 33293182 Test: Built and ran backtrace_test on an angler. Stepped through the Test: modified code and verified it is called and allocated properly. Test: Ran valgrind on the backtrace_test.local_trace to verify that Test: the memory is not leaked. Change-Id: I298e72d6b87d2701111c4659c46246b308f275e9 (cherry picked from commit 50270d3ef2127372c0ae6aefd9be255ab901f573)
-rw-r--r--src/os-linux.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/os-linux.c b/src/os-linux.c
index 7062a1b5..8dc1ebfc 100644
--- a/src/os-linux.c
+++ b/src/os-linux.c
@@ -40,7 +40,7 @@ map_create_list (int map_create_type, pid_t pid)
struct map_info *map_list = NULL;
struct map_info *cur_map;
unw_addr_space_t as = NULL;
- struct unw_addr_space local_as;
+ struct unw_addr_space* local_as = NULL;
void* as_arg = NULL;
if (maps_init (&mi, pid) < 0)
@@ -100,8 +100,14 @@ map_create_list (int map_create_type, pid_t pid)
{
if (map_create_type == UNW_MAP_CREATE_LOCAL)
{
- as = &local_as;
- unw_local_access_addr_space_init (as);
+ // This is a very large structure, so allocate it.
+ if (local_as == NULL)
+ local_as = (struct unw_addr_space*) malloc(sizeof(*local_as));
+ if (local_as != NULL)
+ {
+ as = local_as;
+ unw_local_access_addr_space_init (as);
+ }
}
else
{
@@ -147,6 +153,8 @@ map_create_list (int map_create_type, pid_t pid)
_UPT_destroy (as_arg);
}
+ free(local_as);
+
return map_list;
}
/* End of ANDROID update. */