>Submitter-Id:  net
>Originator:    Mirko Maischberger
>Confidential:  no
>Synopsis:      valgrind reports memleak when std::ios:sync_with_stdio(false)
>Severity:      serious
>Priority:      low
>Category:      libstdc++
>Class:         sw-bug
>Release:       gcc-4.1 (GCC) 4.1.1 20060511 (prerelease) (Debian 4.1.0-4)
>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
>Description:
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.
>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;
}
>Fix:
std::ios::sync_with_stdio(true);


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to