Summary: | objdump debug dump memory leaks | ||
---|---|---|---|
Product: | binutils | Reporter: | 15664243668 |
Component: | binutils | Assignee: | Alan Modra <amodra> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 2.35 | ||
Target Milestone: | 2.36 | ||
Host: | Target: | ||
Build: | Last reconfirmed: | 2020-08-14 00:00:00 | |
Attachments: | PoC |
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=82fcdb39388c6690699d41b7022b054c2de2554c commit 82fcdb39388c6690699d41b7022b054c2de2554c Author: Alan Modra <amodra@gmail.com> Date: Fri Aug 14 20:19:39 2020 +0930 PR26388, objdump debug dump memory leaks num_debug_info_entries is used not just as a count but also as a flag (DEBUG_INFO_UNAVAILABLE) after some errors. That means num_debug_info_entries can't be used when cleaning up malloc'd info. PR 26388 * dwarf.c (free_debug_memory): Free alloc_num_debug_info_entries of debug_information. Correct test of max_loc_offsets and max_range_lists. * rddbg.c (read_debugging_info): Free dhandle on error. Fixed. |
Created attachment 12771 [details] PoC I have found a memory leak in xmalloc and xrealloc of Binutils-2.35. This bug is triggered as $./objdump –dwarf-check -C -g -f -dwarf -x PoC I compile the binutils-2.35 to the 64-bit LSB version with AddressSanitizer in Ubuntu 16.04 and print the debug information. ... ================================================================= ==4710==ERROR: LeakSanitizer: detected memory leaks Direct leak of 8192 byte(s) in 1 object(s) allocated from: #0 0x7f665e4de602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602) #1 0xb36457 in xrealloc ../../libiberty/xmalloc.c:177 Direct leak of 96 byte(s) in 1 object(s) allocated from: #0 0x7f665e4de602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602) #1 0xb362dc in xmalloc ../../libiberty/xmalloc.c:147 SUMMARY: AddressSanitizer: 8288 byte(s) leaked in 2 allocation(s).