libstdc++/9147: Memory leak resulting from std::valarray->push_back(arg)

doolin@ce.berkeley.edu doolin@ce.berkeley.edu
Thu Jan 2 22:36:00 GMT 2003


>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:



More information about the Gcc-bugs mailing list