Created attachment 10486 [details] poc of memory leak The command I execute is "nm-new -A -a -l -S -s --special-syms --synthetic --with-symbol-versions -D leak3.elf", the output is as follows: ================================================================= ==35671==ERROR: LeakSanitizer: detected memory leaks Direct leak of 24 byte(s) in 1 object(s) allocated from: #0 0x7f422f137602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602) #1 0x6b48a5 in objalloc_create objalloc.c:91 #2 0x42525d in bfd_hash_table_init_n /work/binutils-gdb-asan/bfd/hash.c:385 #3 0x4255c9 in bfd_hash_table_init /work/binutils-gdb-asan/bfd/hash.c:417 #4 0x53d56f in create_info_hash_table dwarf2.c:463 #5 0x54e1aa in stash_maybe_enable_info_hash_tables dwarf2.c:4204 #6 0x550182 in _bfd_dwarf2_find_nearest_line dwarf2.c:4613 #7 0x4c13d9 in _bfd_elf_find_line /work/binutils-gdb-asan/bfd/elf.c:8695 #8 0x406aa9 in print_symbol /work/binutils-gdb-asan/binutils/nm.c:1003 #9 0x4070a2 in print_symbols /work/binutils-gdb-asan/binutils/nm.c:1084 #10 0x407a61 in display_rel_file /work/binutils-gdb-asan/binutils/nm.c:1200 #11 0x408276 in display_file /work/binutils-gdb-asan/binutils/nm.c:1320 #12 0x409e3e in main /work/binutils-gdb-asan/binutils/nm.c:1794 #13 0x7f422eaf182f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) Direct leak of 24 byte(s) in 1 object(s) allocated from: #0 0x7f422f137602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602) #1 0x6b48a5 in objalloc_create objalloc.c:91 #2 0x42525d in bfd_hash_table_init_n /work/binutils-gdb-asan/bfd/hash.c:385 #3 0x4255c9 in bfd_hash_table_init /work/binutils-gdb-asan/bfd/hash.c:417 #4 0x53d56f in create_info_hash_table dwarf2.c:463 #5 0x54e169 in stash_maybe_enable_info_hash_tables dwarf2.c:4203 #6 0x550182 in _bfd_dwarf2_find_nearest_line dwarf2.c:4613 #7 0x4c13d9 in _bfd_elf_find_line /work/binutils-gdb-asan/bfd/elf.c:8695 #8 0x406aa9 in print_symbol /work/binutils-gdb-asan/binutils/nm.c:1003 #9 0x4070a2 in print_symbols /work/binutils-gdb-asan/binutils/nm.c:1084 #10 0x407a61 in display_rel_file /work/binutils-gdb-asan/binutils/nm.c:1200 #11 0x408276 in display_file /work/binutils-gdb-asan/binutils/nm.c:1320 #12 0x409e3e in main /work/binutils-gdb-asan/binutils/nm.c:1794 #13 0x7f422eaf182f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) Indirect leak of 32424 byte(s) in 1 object(s) allocated from: #0 0x7f422f137602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602) #1 0x6b4b2a in _objalloc_alloc objalloc.c:143 #2 0x4253ca in bfd_hash_table_init_n /work/binutils-gdb-asan/bfd/hash.c:392 #3 0x4255c9 in bfd_hash_table_init /work/binutils-gdb-asan/bfd/hash.c:417 #4 0x53d56f in create_info_hash_table dwarf2.c:463 #5 0x54e1aa in stash_maybe_enable_info_hash_tables dwarf2.c:4204 #6 0x550182 in _bfd_dwarf2_find_nearest_line dwarf2.c:4613 #13 0x7f422eaf182f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) Indirect leak of 32424 byte(s) in 1 object(s) allocated from: #0 0x7f422f137602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602) #1 0x6b4b2a in _objalloc_alloc objalloc.c:143 #2 0x4253ca in bfd_hash_table_init_n /work/binutils-gdb-asan/bfd/hash.c:392 #3 0x4255c9 in bfd_hash_table_init /work/binutils-gdb-asan/bfd/hash.c:417 #4 0x53d56f in create_info_hash_table dwarf2.c:463 #5 0x54e169 in stash_maybe_enable_info_hash_tables dwarf2.c:4203 #6 0x550182 in _bfd_dwarf2_find_nearest_line dwarf2.c:4613 #7 0x4c13d9 in _bfd_elf_find_line /work/binutils-gdb-asan/bfd/elf.c:8695 #8 0x406aa9 in print_symbol /work/binutils-gdb-asan/binutils/nm.c:1003 #9 0x4070a2 in print_symbols /work/binutils-gdb-asan/binutils/nm.c:1084 #10 0x407a61 in display_rel_file /work/binutils-gdb-asan/binutils/nm.c:1200 #11 0x408276 in display_file /work/binutils-gdb-asan/binutils/nm.c:1320 #12 0x409e3e in main /work/binutils-gdb-asan/binutils/nm.c:1794 #13 0x7f422eaf182f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) Indirect leak of 4064 byte(s) in 1 object(s) allocated from: #0 0x7f422f137602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602) #1 0x6b48c4 in objalloc_create objalloc.c:95 #2 0x42525d in bfd_hash_table_init_n /work/binutils-gdb-asan/bfd/hash.c:385 #3 0x4255c9 in bfd_hash_table_init /work/binutils-gdb-asan/bfd/hash.c:417 #4 0x53d56f in create_info_hash_table dwarf2.c:463 #5 0x54e169 in stash_maybe_enable_info_hash_tables dwarf2.c:4203 #6 0x550182 in _bfd_dwarf2_find_nearest_line dwarf2.c:4613 #7 0x4c13d9 in _bfd_elf_find_line /work/binutils-gdb-asan/bfd/elf.c:8695 #8 0x406aa9 in print_symbol /work/binutils-gdb-asan/binutils/nm.c:1003 #9 0x4070a2 in print_symbols /work/binutils-gdb-asan/binutils/nm.c:1084 #10 0x407a61 in display_rel_file /work/binutils-gdb-asan/binutils/nm.c:1200 #11 0x408276 in display_file /work/binutils-gdb-asan/binutils/nm.c:1320 #12 0x409e3e in main /work/binutils-gdb-asan/binutils/nm.c:1794 #13 0x7f422eaf182f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) Indirect leak of 4064 byte(s) in 1 object(s) allocated from: #0 0x7f422f137602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602) #1 0x6b48c4 in objalloc_create objalloc.c:95 #2 0x42525d in bfd_hash_table_init_n /work/binutils-gdb-asan/bfd/hash.c:385 #3 0x4255c9 in bfd_hash_table_init /work/binutils-gdb-asan/bfd/hash.c:417 #4 0x53d56f in create_info_hash_table dwarf2.c:463 #5 0x54e1aa in stash_maybe_enable_info_hash_tables dwarf2.c:4204 #6 0x550182 in _bfd_dwarf2_find_nearest_line dwarf2.c:4613 #7 0x4c13d9 in _bfd_elf_find_line /work/binutils-gdb-asan/bfd/elf.c:8695 #8 0x406aa9 in print_symbol /work/binutils-gdb-asan/binutils/nm.c:1003 #9 0x4070a2 in print_symbols /work/binutils-gdb-asan/binutils/nm.c:1084 #10 0x407a61 in display_rel_file /work/binutils-gdb-asan/binutils/nm.c:1200 #11 0x408276 in display_file /work/binutils-gdb-asan/binutils/nm.c:1320 #12 0x409e3e in main /work/binutils-gdb-asan/binutils/nm.c:1794 #13 0x7f422eaf182f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) SUMMARY: AddressSanitizer: 73024 byte(s) leaked in 6 allocation(s). The poc is attached here.
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b55ec8b676ed05d93ee49d6c79ae0403616c4fb0 commit b55ec8b676ed05d93ee49d6c79ae0403616c4fb0 Author: Alan Modra <amodra@gmail.com> Date: Mon Oct 9 13:21:44 2017 +1030 PR22212, memory leak in nm PR 22212 * dwarf2.c (_bfd_dwarf2_cleanup_debug_info): Free funcinfo_hash_table and varinfo_hash_table.
Fixed