From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23535 invoked by alias); 2 Jan 2003 23:16:03 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 23497 invoked by uid 71); 2 Jan 2003 23:16:02 -0000 Date: Thu, 02 Jan 2003 23:16:00 -0000 Message-ID: <20030102231602.23496.qmail@sources.redhat.com> To: bkoz@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: David Doolin Subject: Re: libstdc++/9147: Memory leak resulting from std::valarray->push_back(arg) Reply-To: David Doolin X-SW-Source: 2003-01/txt/msg00163.txt.bz2 List-Id: The following reply was made to PR libstdc++/9147; it has been noted by GNATS. From: David Doolin To: bkoz@gcc.gnu.org, bkoz@gcc.gnu.org, doolin@ce.Berkeley.EDU, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org Cc: Subject: Re: libstdc++/9147: Memory leak resulting from std::valarray->push_back(arg) Date: Thu, 2 Jan 2003 15:06:56 -0800 (PST) On 2 Jan 2003 bkoz@gcc.gnu.org wrote: > Synopsis: Memory leak resulting from std::valarray->push_back(arg) > > Responsible-Changed-From-To: unassigned->bkoz > Responsible-Changed-By: bkoz > Responsible-Changed-When: Thu Jan 2 15:01:58 2003 > Responsible-Changed-Why: > Mine. > State-Changed-From-To: open->feedback > State-Changed-By: bkoz > State-Changed-When: Thu Jan 2 15:01:58 2003 > State-Changed-Why: > You seem a bit confused. First, there is no push_back method for valarray. Second, this simple program: You are quite correct, I meant vector! Darn! > > #include > > int main() > { > std::valarray a(20); > a.resize(40); > return 0; > } > > Shows no valgrind leaks. > > More on that part: you'll need to use valgrind 1.0.4 or later with gcc-3.2 toolchains (as indicated by the valgrind RELEASE NOTES: I suggest a careful reading.) Ok, good to know... > > After that, I suggest this page, which has gcc/libstdc++ specific hints on how to use valgrind: > http://gcc.gnu.org/onlinedocs/libstdc++/debug.html I haven't seen this one yet, will check it out... > > Sadly, 3.2.0 shipped with some memory leaks that have since been fixed in the 3.2.1 release: I suggest you use the later version of gcc if possible. Excellent. > > Here is the valgrind output for 3.2.1, running on linux. The leaks shown (8bytes) are known issues: Ok, I will read this carefully, and watch the gcc pages as well. Thanks for your time, this has been very helpful and I will do better next time I file an bug. Dave Doolin > > %valgrind.sh a.out > ==3718== valgrind-1.0.4, a memory error detector for x86 GNU/Linux. > ==3718== Copyright (C) 2000-2002, and GNU GPL'd, by Julian Seward. > ==3718== Startup, with flags: > ==3718== --suppressions=/mnt/hd/bld/H-x86-valgrind/lib/valgrind/default.supp > ==3718== -v > ==3718== --num-callers=20 > ==3718== --leak-check=yes > ==3718== --leak-resolution=high > ==3718== --show-reachable=yes > ==3718== Reading suppressions file: /mnt/hd/bld/H-x86-valgrind/lib/valgrind/default.supp > ==3718== Reading syms from /home/bkoz/a.out > ==3718== Reading syms from /lib/ld-2.3.1.so > ==3718== object doesn't have any debug info > ==3718== Reading syms from /mnt/hd/bld/H-x86-valgrind/lib/valgrind/valgrind.so > ==3718== Reading syms from /mnt/hd/bld/H-x86-gcc-3.2.1/lib/libstdc++.so.5.0.1 > ==3718== Reading syms from /lib/i686/libm-2.3.1.so > ==3718== object doesn't have any debug info > ==3718== Reading syms from /mnt/hd/bld/H-x86-gcc-3.2.1/lib/libgcc_s.so.1 > ==3718== Reading syms from /lib/i686/libc-2.3.1.so > ==3718== object doesn't have any debug info > ==3718== Estimated CPU clock rate is 751 MHz > ==3718== > ==3718== > ==3718== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) > ==3718== malloc/free: in use at exit: 8 bytes in 4 blocks. > ==3718== malloc/free: 6 allocs, 2 frees, 488 bytes allocated. > ==3718== > ==3718== searching for pointers to 4 not-freed blocks. > ==3718== checked 4459624 bytes. > ==3718== > ==3718== definitely lost: 0 bytes in 0 blocks. > ==3718== possibly lost: 0 bytes in 0 blocks. > ==3718== still reachable: 8 bytes in 4 blocks. > ==3718== > ==3718== 2 bytes in 1 blocks are still reachable in loss record 1 of 4 > ==3718== at 0x4003C9D1: __builtin_vec_new (/mnt/hd/src/valgrind-1.0.4/vg_clientfuncs.c:156) > ==3718== by 0x4003CA1A: operator new[](unsigned) (/mnt/hd/src/valgrind-1.0.4/vg_clientfuncs.c:170) > ==3718== by 0x402A3589: std::locale::_Impl::_Impl(std::locale::facet**, unsigned, bool) (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/bits/locale_facets.h:1643) > ==3718== by 0x4028513A: std::locale::classic() (/mnt/hd/src/gcc-3.2.1/libstdc++-v3/libsupc++/new:89) > ==3718== by 0x402839C5: std::locale::locale() (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/bits/localefwd.h:298) > ==3718== by 0x402747C7: ??? (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/streambuf:356) > ==3718== by 0x40273512: __gnu_cxx::stdio_filebuf >::stdio_filebuf(_IO_FILE*, std::_Ios_Openmode, int) (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/ext/stdio_filebuf.h:146) > ==3718== by 0x4027CC67: std::ios_base::Init::_S_ios_create(bool) (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/bits/basic_ios.h:186) > ==3718== by 0x4027D235: std::ios_base::Init::Init() (/mnt/hd/src/gcc-3.2.1/libstdc++-v3/src/ios.cc:211) > ==3718== by 0x4027C9B8: __static_initialization_and_destruction_0(int, int) (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/iostream:63) > ==3718== by 0x4027CA2A: _GLOBAL__I__ZThn8_NSt14basic_iostreamIwSt11char_traitsIwEED0Ev_mnt_hd_src_gcc_3.2.1_libstdc___v3_src_io_inst.ccWrimhb (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/bits/locale_facets.h:107)==3718== by 0x402C8B35: (within /mnt/hd/bld/H-x86-gcc-3.2.1/lib/libstdc++.so.5.0.1) > ==3718== by 0x4026D14E: ??? (/tmp/ccv5AQuj.s:25) > ==3718== by 0x4000A66E: call_init (in /lib/ld-2.3.1.so) > ==3718== by 0x4000A4DA: _dl_init_internal (in /lib/ld-2.3.1.so) > ==3718== by 0x40000AAD: (within /lib/ld-2.3.1.so) > ==3718== > ==3718== 2 bytes in 1 blocks are still reachable in loss record 2 of 4 > ==3718== at 0x4003C9D1: __builtin_vec_new (/mnt/hd/src/valgrind-1.0.4/vg_clientfuncs.c:156) > ==3718== by 0x4003CA1A: operator new[](unsigned) (/mnt/hd/src/valgrind-1.0.4/vg_clientfuncs.c:170) > ==3718== by 0x402A3490: std::locale::_Impl::_Impl(std::locale::facet**, unsigned, bool) (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/bits/locale_facets.h:1017) > ==3718== by 0x4028513A: std::locale::classic() (/mnt/hd/src/gcc-3.2.1/libstdc++-v3/libsupc++/new:89) > ==3718== by 0x402839C5: std::locale::locale() (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/bits/localefwd.h:298) > ==3718== by 0x402747C7: ??? (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/streambuf:356) > ==3718== by 0x40273512: __gnu_cxx::stdio_filebuf >::stdio_filebuf(_IO_FILE*, std::_Ios_Openmode, int) (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/ext/stdio_filebuf.h:146) > ==3718== by 0x4027CC67: std::ios_base::Init::_S_ios_create(bool) (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/bits/basic_ios.h:186) > ==3718== by 0x4027D235: std::ios_base::Init::Init() (/mnt/hd/src/gcc-3.2.1/libstdc++-v3/src/ios.cc:211) > ==3718== by 0x4027C9B8: __static_initialization_and_destruction_0(int, int) (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/iostream:63) > ==3718== by 0x4027CA2A: _GLOBAL__I__ZThn8_NSt14basic_iostreamIwSt11char_traitsIwEED0Ev_mnt_hd_src_gcc_3.2.1_libstdc___v3_src_io_inst.ccWrimhb (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/bits/locale_facets.h:107)==3718== by 0x402C8B35: (within /mnt/hd/bld/H-x86-gcc-3.2.1/lib/libstdc++.so.5.0.1) > ==3718== by 0x4026D14E: ??? (/tmp/ccv5AQuj.s:25) > ==3718== by 0x4000A66E: call_init (in /lib/ld-2.3.1.so) > ==3718== by 0x4000A4DA: _dl_init_internal (in /lib/ld-2.3.1.so) > ==3718== by 0x40000AAD: (within /lib/ld-2.3.1.so) > ==3718== > ==3718== 2 bytes in 1 blocks are still reachable in loss record 3 of 4 > ==3718== at 0x4003C9D1: __builtin_vec_new (/mnt/hd/src/valgrind-1.0.4/vg_clientfuncs.c:156) > ==3718== by 0x4003CA1A: operator new[](unsigned) (/mnt/hd/src/valgrind-1.0.4/vg_clientfuncs.c:170) > ==3718== by 0x402A312F: std::locale::_Impl::_Impl(std::locale::facet**, unsigned, bool) (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/bits/locale_facets.h:1643) > ==3718== by 0x4028513A: std::locale::classic() (/mnt/hd/src/gcc-3.2.1/libstdc++-v3/libsupc++/new:89) > ==3718== by 0x402839C5: std::locale::locale() (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/bits/localefwd.h:298) > ==3718== by 0x402747C7: ??? (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/streambuf:356) > ==3718== by 0x40273512: __gnu_cxx::stdio_filebuf >::stdio_filebuf(_IO_FILE*, std::_Ios_Openmode, int) (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/ext/stdio_filebuf.h:146) > ==3718== by 0x4027CC67: std::ios_base::Init::_S_ios_create(bool) (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/bits/basic_ios.h:186) > ==3718== by 0x4027D235: std::ios_base::Init::Init() (/mnt/hd/src/gcc-3.2.1/libstdc++-v3/src/ios.cc:211) > ==3718== by 0x4027C9B8: __static_initialization_and_destruction_0(int, int) (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/iostream:63) > ==3718== by 0x4027CA2A: _GLOBAL__I__ZThn8_NSt14basic_iostreamIwSt11char_traitsIwEED0Ev_mnt_hd_src_gcc_3.2.1_libstdc___v3_src_io_inst.ccWrimhb (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/bits/locale_facets.h:107)==3718== by 0x402C8B35: (within /mnt/hd/bld/H-x86-gcc-3.2.1/lib/libstdc++.so.5.0.1) > ==3718== by 0x4026D14E: ??? (/tmp/ccv5AQuj.s:25) > ==3718== by 0x4000A66E: call_init (in /lib/ld-2.3.1.so) > ==3718== by 0x4000A4DA: _dl_init_internal (in /lib/ld-2.3.1.so) > ==3718== by 0x40000AAD: (within /lib/ld-2.3.1.so) > ==3718== > ==3718== 2 bytes in 1 blocks are still reachable in loss record 4 of 4 > ==3718== at 0x4003C9D1: __builtin_vec_new (/mnt/hd/src/valgrind-1.0.4/vg_clientfuncs.c:156) > ==3718== by 0x4003CA1A: operator new[](unsigned) (/mnt/hd/src/valgrind-1.0.4/vg_clientfuncs.c:170) > ==3718== by 0x402A3032: std::locale::_Impl::_Impl(std::locale::facet**, unsigned, bool) (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/bits/locale_facets.h:1017) > ==3718== by 0x4028513A: std::locale::classic() (/mnt/hd/src/gcc-3.2.1/libstdc++-v3/libsupc++/new:89) > ==3718== by 0x402839C5: std::locale::locale() (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/bits/localefwd.h:298) > ==3718== by 0x402747C7: ??? (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/streambuf:356) > ==3718== by 0x40273512: __gnu_cxx::stdio_filebuf >::stdio_filebuf(_IO_FILE*, std::_Ios_Openmode, int) (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/ext/stdio_filebuf.h:146) > ==3718== by 0x4027CC67: std::ios_base::Init::_S_ios_create(bool) (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/bits/basic_ios.h:186) > ==3718== by 0x4027D235: std::ios_base::Init::Init() (/mnt/hd/src/gcc-3.2.1/libstdc++-v3/src/ios.cc:211) > ==3718== by 0x4027C9B8: __static_initialization_and_destruction_0(int, int) (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/iostream:63) > ==3718== by 0x4027CA2A: _GLOBAL__I__ZThn8_NSt14basic_iostreamIwSt11char_traitsIwEED0Ev_mnt_hd_src_gcc_3.2.1_libstdc___v3_src_io_inst.ccWrimhb (/mnt/hd/bld/bld-x86-gcc-3.2.1/i686-pc-linux-gnu/libstdc++-v3/include/bits/locale_facets.h:107)==3718== by 0x402C8B35: (within /mnt/hd/bld/H-x86-gcc-3.2.1/lib/libstdc++.so.5.0.1) > ==3718== by 0x4026D14E: ??? (/tmp/ccv5AQuj.s:25) > ==3718== by 0x4000A66E: call_init (in /lib/ld-2.3.1.so) > ==3718== by 0x4000A4DA: _dl_init_internal (in /lib/ld-2.3.1.so) > ==3718== by 0x40000AAD: (within /lib/ld-2.3.1.so) > ==3718== > ==3718== LEAK SUMMARY: > ==3718== definitely lost: 0 bytes in 0 blocks. > ==3718== possibly lost: 0 bytes in 0 blocks. > ==3718== still reachable: 8 bytes in 4 blocks. > ==3718== > --3718-- lru: 0 epochs, 0 clearings. > --3718-- translate: new 1485 (22684 -> 269355), discard 0 (0 -> 0). > --3718-- dispatch: 0 basic blocks, 2/1516 sched events, 1505 tt_fast misses. > --3718-- reg-alloc: 424 t-req-spill, 49567+2984 orig+spill uis, 7245 total-reg-r. > --3718-- sanity: 3 cheap, 1 expensive checks. > > > > > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9147 >