This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/27931] New: valgrind reports memleak when std::ios:sync_with_stdio(false)
- From: "gcc-bugzilla at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Jun 2006 14:40:41 -0000
- Subject: [Bug libstdc++/27931] New: valgrind reports memleak when std::ios:sync_with_stdio(false)
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
A memory leak happens when std::ios::sync_with_stdio(false);
valgrind:
...
==13644==
==13644== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 17 from 1)
==13644== malloc/free: in use at exit: 122,880 bytes in 6 blocks.
==13644== malloc/free: 6 allocs, 0 frees, 122,880 bytes allocated.
==13644== For counts of detected errors, rerun with: -v
==13644== searching for pointers to 6 not-freed blocks.
==13644== checked 96,388 bytes.
==13644==
==13644== 24,576 bytes in 3 blocks are still reachable in loss record 1 of 2
==13644== at 0x401BCC9: operator new[](unsigned) (vg_replace_malloc.c:197)
==13644== by 0x4090D7B: std::basic_filebuf<char, std::char_traits<char>
>::_M_allocate_internal_buffer() (in
/usr/lib/libstdc++.so.6.0.8)
==13644== by 0x4098805: (within /usr/lib/libstdc++.so.6.0.8)
==13644== by 0x40862D6: std::ios_base::sync_with_stdio(bool) (in
/usr/lib/libstdc++.so.6.0.8)
==13644== by 0x8048712: main (in ...)
==13644==
==13644==
==13644== 98,304 bytes in 3 blocks are still reachable in loss record 2 of 2
==13644== at 0x401BCC9: operator new[](unsigned) (vg_replace_malloc.c:197)
==13644== by 0x4090D2E: std::basic_filebuf<wchar_t,
std::char_traits<wchar_t> >::_M_allocate_internal_buffer() (in
/usr/lib/libstdc++.so.6.0.8)
==13644== by 0x40981F5: (within /usr/lib/libstdc++.so.6.0.8)
==13644== by 0x40863B4: std::ios_base::sync_with_stdio(bool) (in
/usr/lib/libstdc++.so.6.0.8)
==13644== by 0x8048712: main (in ...)
==13644==
==13644== LEAK SUMMARY:
==13644== definitely lost: 0 bytes in 0 blocks.
==13644== possibly lost: 0 bytes in 0 blocks.
==13644== still reachable: 122,880 bytes in 6 blocks.
==13644== suppressed: 0 bytes in 0 blocks.
Environment:
System: Linux penelope 2.6.15-1-k7 #2 Mon Mar 6 15:42:39 UTC 2006 i686
GNU/Linux
Architecture: i686
host: i486-pc-linux-gnu
build: i486-pc-linux-gnu
target: i486-pc-linux-gnu
configured with: ../src/configure -v
--enable-languages=c,c++,java,fortran,objc,obj-c++,ada,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/jre --enable-mpfr
--with-tune=i686 --enable-checking=release i486-linux-gnu
How-To-Repeat:
// run with valgrind --leak-check=full --show-reachable=yes
#include <iostream>
int
main(void)
{
std::ios::sync_with_stdio(false);
std::cout << "testing" << std::endl;
return 0;
}
------- Comment #1 from mirko dot maischberger at gmail dot com 2006-06-07 14:40 -------
Fix:
std::ios::sync_with_stdio(true);
--
Summary: valgrind reports memleak when
std::ios:sync_with_stdio(false)
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mirko dot maischberger at gmail dot com
GCC build triplet: i486-pc-linux-gnu
GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27931