public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* libstdc++/9147: Memory leak resulting from std::valarray->push_back(arg)
@ 2003-01-02 22:36 doolin
  0 siblings, 0 replies; 4+ messages in thread
From: doolin @ 2003-01-02 22:36 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9147
>Category:       libstdc++
>Synopsis:       Memory leak resulting from std::valarray->push_back(arg)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 02 14:36:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     doolin@ce.berkeley.edu
>Release:        g++-3.2
>Organization:
>Environment:
GNU/Linux
>Description:
Memory leak in valarray and vg_clientfuncs.c:


dave@dda:~/sf.net/geotechnica/projects/stratsection/test$ !va
valgrind --leak-check=yes --show-reachable=yes ./coltest
==4378== valgrind-1.0.3, a memory error detector for x86 GNU/Linux.
==4378== Copyright (C) 2000-2002, and GNU GPL'd, by Julian Seward.
==4378== Estimated CPU clock rate is 552 MHz
==4378== For more details, rerun with: -v
==4378== 
Sum: 20
RSum: 20
==4378== 
==4378== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==4378== malloc/free: in use at exit: 2640 bytes in 3 blocks.
==4378== malloc/free: 7 allocs, 4 frees, 2724 bytes allocated.
==4378== For counts of detected errors, rerun with: -v
==4378== searching for pointers to 3 not-freed blocks.
==4378== checked 4400124 bytes.
==4378== 
==4378== definitely lost: 16 bytes in 1 blocks.
==4378== possibly lost:   0 bytes in 0 blocks.
==4378== still reachable: 2624 bytes in 2 blocks.
==4378== 
==4378== 16 bytes in 1 blocks are definitely lost in loss record 1 of 3
==4378==    at 0x4004491B: malloc (vg_clientfuncs.c:100)
==4378==    by 0x40044E84: realloc (vg_clientfuncs.c:262)
==4378==    by 0x4038F83B: (within /lib/libc-2.2.5.so)
==4378==    by 0x4033D166: (within /lib/libc-2.2.5.so)
==4378== 
==4378== 64 bytes in 1 blocks are still reachable in loss record 2 of 3
==4378==    at 0x4004491B: malloc (vg_clientfuncs.c:100)
==4378==    by 0x4033D35F: (within /lib/libc-2.2.5.so)
==4378==    by 0x402C7560: (within /usr/lib/libstdc++.so.5.0.1)
==4378==    by 0x40295420: (within /usr/lib/libstdc++.so.5.0.1)
==4378== 
==4378== 2560 bytes in 1 blocks are still reachable in loss record 3 of 3
==4378==    at 0x40044A0B: __builtin_new (vg_clientfuncs.c:125)
==4378==    by 0x40044A51: operator new(unsigned) (vg_clientfuncs.c:138)
==4378==    by 0x402B81DB: (within /usr/lib/libstdc++.so.5.0.1)
==4378==    by 0x402B80F0: (within /usr/lib/libstdc++.so.5.0.1)
==4378== 
==4378== LEAK SUMMARY:
==4378==    definitely lost: 16 bytes in 1 blocks.
==4378==    possibly lost:   0 bytes in 0 blocks.
==4378==    still reachable: 2624 bytes in 2 blocks.
==4378== 
dave@dda:~/sf.net/geotechnica/projects/stratsection/test$ 
>How-To-Repeat:
Use std::valarray->push_back(arg).

I would be willing to submit an example if I don't get flamed too hard.  If I get some time in a couple of weeks, I may even try to fix it.
>Fix:
Add a call to free() in the appropriate places.
>Release-Note:
>Audit-Trail:
>Unformatted:


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

* Re: libstdc++/9147: Memory leak resulting from std::valarray->push_back(arg)
@ 2003-01-06 20:39 bkoz
  0 siblings, 0 replies; 4+ messages in thread
From: bkoz @ 2003-01-06 20:39 UTC (permalink / raw)
  To: bkoz, doolin, gcc-bugs, gcc-prs

Synopsis: Memory leak resulting from std::valarray->push_back(arg)

State-Changed-From-To: feedback->closed
State-Changed-By: bkoz
State-Changed-When: Mon Jan  6 12:39:52 2003
State-Changed-Why:
    Fixed. Additonal patching to remove all leaks.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9147


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

* Re: libstdc++/9147: Memory leak resulting from std::valarray->push_back(arg)
@ 2003-01-02 23:16 David Doolin
  0 siblings, 0 replies; 4+ messages in thread
From: David Doolin @ 2003-01-02 23:16 UTC (permalink / raw)
  To: bkoz; +Cc: gcc-prs

The following reply was made to PR libstdc++/9147; it has been noted by GNATS.

From: David Doolin <doolin@alpha-1.CE.Berkeley.EDU>
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 <valarray>
 >     
 >     int main()
 >     {
 >       std::valarray<double> 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<char, std::char_traits<char> >::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<char, std::char_traits<char> >::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<char, std::char_traits<char> >::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<char, std::char_traits<char> >::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
 > 
 


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

* Re: libstdc++/9147: Memory leak resulting from std::valarray->push_back(arg)
@ 2003-01-02 23:01 bkoz
  0 siblings, 0 replies; 4+ messages in thread
From: bkoz @ 2003-01-02 23:01 UTC (permalink / raw)
  To: bkoz, doolin, gcc-bugs, gcc-prs, nobody

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:
    
    #include <valarray>
    
    int main()
    {
      std::valarray<double> 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.) 
    
    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
    
    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.
    
    Here is the valgrind output for 3.2.1, running on linux. The leaks shown (8bytes) are known issues:
    
    %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<char, std::char_traits<char> >::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<char, std::char_traits<char> >::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<char, std::char_traits<char> >::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<char, std::char_traits<char> >::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


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

end of thread, other threads:[~2003-01-06 20:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-02 22:36 libstdc++/9147: Memory leak resulting from std::valarray->push_back(arg) doolin
2003-01-02 23:01 bkoz
2003-01-02 23:16 David Doolin
2003-01-06 20:39 bkoz

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