diff options
author | Christopher Ferris <cferris@google.com> | 2016-12-02 10:22:45 -0800 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2016-12-05 07:54:14 -0800 |
commit | f7eef920b5a22f5e1635ed61c703b6400758436a (patch) | |
tree | f201eba89c88f8bcdc0a178d51c99d374da45990 | |
parent | d35224ff189bf5fed77bfcc36c790c8dd205d0e0 (diff) | |
download | libunwind-nougat-mr2.2-release.tar.gz |
Move large structure off the stack.android-7.1.2_r9android-7.1.2_r8android-7.1.2_r6android-7.1.2_r5android-7.1.2_r4android-7.1.2_r39android-7.1.2_r38android-7.1.2_r37android-7.1.2_r36android-7.1.2_r33android-7.1.2_r32android-7.1.2_r30android-7.1.2_r3android-7.1.2_r29android-7.1.2_r28android-7.1.2_r27android-7.1.2_r25android-7.1.2_r24android-7.1.2_r23android-7.1.2_r2android-7.1.2_r19android-7.1.2_r18android-7.1.2_r17android-7.1.2_r16android-7.1.2_r15android-7.1.2_r14android-7.1.2_r13android-7.1.2_r12android-7.1.2_r11android-7.1.2_r10android-7.1.2_r1nougat-mr2.3-releasenougat-mr2.2-releasenougat-mr2.1-releasenougat-mr2-security-releasenougat-mr2-releasenougat-mr2-pixel-releasenougat-mr2-dev
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.c | 14 |
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. */ |