From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7EF1D3858D28; Tue, 12 Apr 2022 14:49:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7EF1D3858D28 From: "redi at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libbacktrace X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Apr 2022 14:49:04 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105240 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=3Dfull ./stacktrace =3D=3D297621=3D=3D Memcheck, a memory error detector =3D=3D297621=3D=3D Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward= et al. =3D=3D297621=3D=3D Using Valgrind-3.18.1 and LibVEX; rerun with -h for copy= right info =3D=3D297621=3D=3D Command: ./stacktrace =3D=3D297621=3D=3D=20 =3D=3D297621=3D=3D=20 =3D=3D297621=3D=3D HEAP SUMMARY: =3D=3D297621=3D=3D in use at exit: 699,881 bytes in 1,134 blocks =3D=3D297621=3D=3D total heap usage: 2,469 allocs, 1,335 frees, 1,473,361= bytes allocated =3D=3D297621=3D=3D=20 =3D=3D297621=3D=3D 2,286 bytes in 53 blocks are definitely lost in loss rec= ord 12 of 20 =3D=3D297621=3D=3D at 0x484086F: malloc (vg_replace_malloc.c:381) =3D=3D297621=3D=3D by 0x4113F5: __glibcxx_backtrace_alloc (alloc.c:57) =3D=3D297621=3D=3D by 0x413672: read_lnct (dwarf.c:2543) =3D=3D297621=3D=3D by 0x413672: read_line_header_format_entries (dwarf.c= :2618) =3D=3D297621=3D=3D by 0x415286: read_line_header (dwarf.c:2712) =3D=3D297621=3D=3D by 0x415286: read_line_info (dwarf.c:2965) =3D=3D297621=3D=3D by 0x415286: dwarf_lookup_pc (dwarf.c:3747) =3D=3D297621=3D=3D by 0x4162B0: dwarf_fileline (dwarf.c:3935) =3D=3D297621=3D=3D by 0x405B95: std::stacktrace_entry::_M_get_info(std::__cxx11::basic_string, std::allocator >*, std::__cxx11::basic_string, std::allocator >*, int*) const (stacktrace:186) =3D=3D297621=3D=3D by 0x405885: std::stacktrace_entry::source_line() con= st (stacktrace:129) =3D=3D297621=3D=3D by 0x404B08: test_assign() (stacktrace.cc:132) =3D=3D297621=3D=3D by 0x40554E: main (stacktrace.cc:212) =3D=3D297621=3D=3D=20 =3D=3D297621=3D=3D 46,055 bytes in 1 blocks are possibly lost in loss recor= d 17 of 20 =3D=3D297621=3D=3D at 0x484086F: malloc (vg_replace_malloc.c:381) =3D=3D297621=3D=3D by 0x4113F5: __glibcxx_backtrace_alloc (alloc.c:57) =3D=3D297621=3D=3D by 0x4112EA: __glibcxx_backtrace_get_view (read.c:68) =3D=3D297621=3D=3D by 0x410CC3: elf_add.constprop.0 (elf.c:4381) =3D=3D297621=3D=3D by 0x4111E3: __glibcxx_backtrace_initialize (elf.c:48= 77) =3D=3D297621=3D=3D by 0x40BC47: fileline_initialize (fileline.c:261) =3D=3D297621=3D=3D by 0x40BCE5: __glibcxx_backtrace_pcinfo (fileline.c:2= 95) =3D=3D297621=3D=3D by 0x405B95: std::stacktrace_entry::_M_get_info(std::__cxx11::basic_string, std::allocator >*, std::__cxx11::basic_string, std::allocator >*, int*) const (stacktrace:186) =3D=3D297621=3D=3D by 0x405885: std::stacktrace_entry::source_line() con= st (stacktrace:129) =3D=3D297621=3D=3D by 0x404B08: test_assign() (stacktrace.cc:132) =3D=3D297621=3D=3D by 0x40554E: main (stacktrace.cc:212) =3D=3D297621=3D=3D=20 =3D=3D297621=3D=3D LEAK SUMMARY: =3D=3D297621=3D=3D definitely lost: 2,286 bytes in 53 blocks =3D=3D297621=3D=3D indirectly lost: 0 bytes in 0 blocks =3D=3D297621=3D=3D possibly lost: 46,055 bytes in 1 blocks =3D=3D297621=3D=3D still reachable: 651,540 bytes in 1,080 blocks =3D=3D297621=3D=3D suppressed: 0 bytes in 0 blocks =3D=3D297621=3D=3D Reachable blocks (those to which a pointer was found) ar= e not shown. =3D=3D297621=3D=3D To see them, rerun with: --leak-check=3Dfull --show-leak= -kinds=3Dall =3D=3D297621=3D=3D=20 =3D=3D297621=3D=3D For lists of detected and suppressed errors, rerun with:= -s =3D=3D297621=3D=3D ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 f= rom 0) This only happens when libbacktrace uses malloc instead of mmap.=