public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libbacktrace/105240] New: backtrace_pcinfo leaks memory
Date: Tue, 12 Apr 2022 14:49:04 +0000	[thread overview]
Message-ID: <bug-105240-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105240

            Bug ID: 105240
           Summary: backtrace_pcinfo leaks memory
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libbacktrace
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
                CC: ian at gcc dot gnu.org
  Target Milestone: ---

I'm seeing lots of leaked memory for simple uses of libbacktrace:

$ valgrind --leak-check=full  ./stacktrace
==297621== Memcheck, a memory error detector
==297621== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==297621== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==297621== Command: ./stacktrace
==297621== 
==297621== 
==297621== HEAP SUMMARY:
==297621==     in use at exit: 699,881 bytes in 1,134 blocks
==297621==   total heap usage: 2,469 allocs, 1,335 frees, 1,473,361 bytes
allocated
==297621== 
==297621== 2,286 bytes in 53 blocks are definitely lost in loss record 12 of 20
==297621==    at 0x484086F: malloc (vg_replace_malloc.c:381)
==297621==    by 0x4113F5: __glibcxx_backtrace_alloc (alloc.c:57)
==297621==    by 0x413672: read_lnct (dwarf.c:2543)
==297621==    by 0x413672: read_line_header_format_entries (dwarf.c:2618)
==297621==    by 0x415286: read_line_header (dwarf.c:2712)
==297621==    by 0x415286: read_line_info (dwarf.c:2965)
==297621==    by 0x415286: dwarf_lookup_pc (dwarf.c:3747)
==297621==    by 0x4162B0: dwarf_fileline (dwarf.c:3935)
==297621==    by 0x405B95:
std::stacktrace_entry::_M_get_info(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >*,
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>
>*, int*) const (stacktrace:186)
==297621==    by 0x405885: std::stacktrace_entry::source_line() const
(stacktrace:129)
==297621==    by 0x404B08: test_assign() (stacktrace.cc:132)
==297621==    by 0x40554E: main (stacktrace.cc:212)
==297621== 
==297621== 46,055 bytes in 1 blocks are possibly lost in loss record 17 of 20
==297621==    at 0x484086F: malloc (vg_replace_malloc.c:381)
==297621==    by 0x4113F5: __glibcxx_backtrace_alloc (alloc.c:57)
==297621==    by 0x4112EA: __glibcxx_backtrace_get_view (read.c:68)
==297621==    by 0x410CC3: elf_add.constprop.0 (elf.c:4381)
==297621==    by 0x4111E3: __glibcxx_backtrace_initialize (elf.c:4877)
==297621==    by 0x40BC47: fileline_initialize (fileline.c:261)
==297621==    by 0x40BCE5: __glibcxx_backtrace_pcinfo (fileline.c:295)
==297621==    by 0x405B95:
std::stacktrace_entry::_M_get_info(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >*,
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>
>*, int*) const (stacktrace:186)
==297621==    by 0x405885: std::stacktrace_entry::source_line() const
(stacktrace:129)
==297621==    by 0x404B08: test_assign() (stacktrace.cc:132)
==297621==    by 0x40554E: main (stacktrace.cc:212)
==297621== 
==297621== LEAK SUMMARY:
==297621==    definitely lost: 2,286 bytes in 53 blocks
==297621==    indirectly lost: 0 bytes in 0 blocks
==297621==      possibly lost: 46,055 bytes in 1 blocks
==297621==    still reachable: 651,540 bytes in 1,080 blocks
==297621==         suppressed: 0 bytes in 0 blocks
==297621== Reachable blocks (those to which a pointer was found) are not shown.
==297621== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==297621== 
==297621== For lists of detected and suppressed errors, rerun with: -s
==297621== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)


This only happens when libbacktrace uses malloc instead of mmap.

             reply	other threads:[~2022-04-12 14:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12 14:49 redi at gcc dot gnu.org [this message]
2022-04-12 14:50 ` [Bug libbacktrace/105240] " redi at gcc dot gnu.org
2022-04-12 14:52 ` redi at gcc dot gnu.org
2022-04-12 16:31 ` ian at airs dot com
2022-04-12 17:39 ` redi at gcc dot gnu.org
2022-04-12 21:39 ` cvs-commit at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-105240-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).