From b5cbcaee13233ddbc2e6a3fffe85374031f51000 Mon Sep 17 00:00:00 2001 From: Dave Watson Date: Tue, 10 Apr 2018 10:55:34 -0700 Subject: [PATCH] dwarf: do not allocate in load_debug_frame (#72) load_debug_frame calls malloc() in a couple spots, use mmap via GET_MEMORY instead. These call paths are infrequent, and are never freed. Found by running tcmalloc unit tests on aarch64, when DEBUG_FRAME support is on. --- src/dwarf/Gfind_proc_info-lsb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dwarf/Gfind_proc_info-lsb.c b/src/dwarf/Gfind_proc_info-lsb.c index c18783e0..58fa51d0 100644 --- a/src/dwarf/Gfind_proc_info-lsb.c +++ b/src/dwarf/Gfind_proc_info-lsb.c @@ -119,7 +119,7 @@ load_debug_frame (const char *file, char **buf, size_t *bufsize, int is_local) } *bufsize = shdr->sh_size; - *buf = malloc (*bufsize); + GET_MEMORY(*buf, *bufsize); memcpy(*buf, shdr->sh_offset + ei.image, *bufsize); @@ -208,7 +208,7 @@ locate_debug_info (unw_addr_space_t as, unw_word_t addr, const char *dlname, if (!err) { - fdesc = malloc (sizeof (struct unw_debug_frame_list)); + GET_MEMORY(fdesc, sizeof (struct unw_debug_frame_list)); fdesc->start = start; fdesc->end = end;