public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libbacktrace/105240] New: backtrace_pcinfo leaks memory
@ 2022-04-12 14:49 redi at gcc dot gnu.org
  2022-04-12 14:50 ` [Bug libbacktrace/105240] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2022-04-12 14:49 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-04-12 21:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12 14:49 [Bug libbacktrace/105240] New: backtrace_pcinfo leaks memory redi at gcc dot gnu.org
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

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).