Summary: | Memory leak in elf_x86_64_get_synthetic_symtab | ||
---|---|---|---|
Product: | binutils | Reporter: | Bowen Wang <wang8330> |
Component: | binutils | Assignee: | Alan Modra <amodra> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | nickc, wang8330 |
Priority: | P2 | ||
Version: | 2.33 | ||
Target Milestone: | 2.33 | ||
Host: | Target: | ||
Build: | Last reconfirmed: | 2019-08-23 00:00:00 | |
Attachments: | PoC input |
Hi Bowen Thanks for reporting this problem, but we are not going to fix it. Memory leaks for programs like objdump are unimportant. The program always terminates, so the memory is always returned to the system. Plus the program does not stay resident for very long, so it will not consume system resources unreasonably. Cheers Nick Actually, I was in the middle of testing a patch. This one is simple to fix. On 23/08/2019 10:51, amodra at gmail dot com wrote:
> Actually, I was in the middle of testing a patch. This one is simple to fix.
Doh! :-)
Oh well ignore me then. :-)
Cheers
Nick
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2600d80ccd04666f28608364be74d7ee552977ae commit 2600d80ccd04666f28608364be74d7ee552977ae Author: Alan Modra <amodra@gmail.com> Date: Fri Aug 23 19:16:25 2019 +0930 PR24933, Memory leak in elf_x86_64_get_synthetic_symtab PR 24933 * elfxx-x86.c (_bfd_x86_elf_get_synthetic_symtab): Don't exit on error without freeing plts[] contents. Fixed. |
Created attachment 11963 [details] PoC input There is a memory leak bug according to output of Valgrind. This bug is found in git commit: 1aa7f807d239dc32433e5f10840cdc8e80824c64 Compile the target: CFLAGS="-DFORTIFY_SOURCE=2 -fno-omit-frame-pointer -g -Wno-error" \ ./configure \ --disable-shared --disable-gdb --disable-libdecnumber --disable-readline \ --disable-sim To trigger the bug: valgrind --leak-check=full ./objdump -d test-input The output of Valgrind: ==6416== Memcheck, a memory error detector ==6416== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==6416== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info ==6416== Command: ./objdump -d ../../objdump-input/input.15104 ==6416== ./objdump: warning: ../../objdump-input/input.15104 has a corrupt section with a size (8000258) larger than the file size ../../objdump-input/input.15104: file format elf64-x86-64 ./objdump: ../../objdump-input/input.15104: file truncated ==6416== ==6416== HEAP SUMMARY: ==6416== in use at exit: 447,435,832 bytes in 24 blocks ==6416== total heap usage: 288 allocs, 264 frees, 715,909,380 bytes allocated ==6416== ==6416== 776 bytes in 2 blocks are definitely lost in loss record 10 of 22 ==6416== at 0x483874F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==6416== by 0x1DAB2D: bfd_malloc (libbfd.c:275) ==6416== by 0x1F3629: elf_x86_64_get_synthetic_symtab (elf64-x86-64.c:4727) ==6416== by 0x171412: dump_bfd (objdump.c:4047) ==6416== by 0x1716F1: display_object_bfd (objdump.c:4132) ==6416== by 0x17195B: display_any_bfd (objdump.c:4222) ==6416== by 0x1719CF: display_file (objdump.c:4243) ==6416== by 0x17239A: main (objdump.c:4561) ==6416== ==6416== 44,739,824 bytes in 1 blocks are possibly lost in loss record 20 of 22 ==6416== at 0x483874F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==6416== by 0x1DAB2D: bfd_malloc (libbfd.c:275) ==6416== by 0x1F9356: _bfd_x86_elf_get_synthetic_symtab (elfxx-x86.c:2177) ==6416== by 0x1F3C5F: elf_x86_64_get_synthetic_symtab (elf64-x86-64.c:4839) ==6416== by 0x171412: dump_bfd (objdump.c:4047) ==6416== by 0x1716F1: display_object_bfd (objdump.c:4132) ==6416== by 0x17195B: display_any_bfd (objdump.c:4222) ==6416== by 0x1719CF: display_file (objdump.c:4243) ==6416== by 0x17239A: main (objdump.c:4561) ==6416== ==6416== LEAK SUMMARY: ==6416== definitely lost: 776 bytes in 2 blocks ==6416== indirectly lost: 0 bytes in 0 blocks ==6416== possibly lost: 44,739,824 bytes in 1 blocks ==6416== still reachable: 402,695,232 bytes in 21 blocks ==6416== suppressed: 0 bytes in 0 blocks ==6416== Reachable blocks (those to which a pointer was found) are not shown. ==6416== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==6416== ==6416== For counts of detected and suppressed errors, rerun with: -v ==6416== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0) The PoC input is attached.