https://sourceware.org/bugzilla/show_bug.cgi?id=22212

            Bug ID: 22212
           Summary: memory leak in nm in binutils 2.30(HEAD)
           Product: binutils
           Version: 2.30 (HEAD)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: binutils
          Assignee: unassigned at sourceware dot org
          Reporter: luanjunchao at 163 dot com
  Target Milestone: ---

Created attachment 10486
  --> https://sourceware.org/bugzilla/attachment.cgi?id=10486&action=edit
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to