This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/25849] 8 byte memory leak using cerr with libpthread linked in



------- Comment #3 from loizeaux1 at hotmail dot com  2006-01-19 17:30 -------
Here's the results I got after following the directions on the website you gave
me (I realize this may be moot since you pointed out that it is a false
positive, but I'll just do this for completeness' sake):

> cat test.cpp
#include <cstdlib>
#include <iostream>

extern "C" void __libc_freeres(void);

void do_something()
{
   std::cerr << "This is a message" << std::endl;
}

int main ( int argc, char* argv[] )
{
   atexit( __libc_freeres );
   do_something();
   return 0;
}

> g++ -g -O0 -o test test.cpp -lpthread

[Author's note: The webpage you forwarded gave an example of how to use
valgrind.  You left off the --tool option, which may not have been required
with version 1.0.4, but is with 2.2.0 (I have never used valgrind before, and
so I don't know when it may have changed).  I assume you wanted me to use the
"memcheck" tool option.  You might want to have someone look at that page if
you are going to give it to newbies to reference.]

> valgrind -v --tool=memcheck --num-callers=20 --leak-check=yes --leak-resolution=high --show-reachable=yes test
==22877== Memcheck, a memory error detector for x86-linux.
==22877== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward et al.
==22877== Using valgrind-2.2.0, a program supervision framework for x86-linux.
==22877== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward et al.
==22877== Valgrind library directory: /usr/lib/valgrind
==22877== Command line
==22877==    test
==22877== Startup, with flags:
==22877==    -v
==22877==    --tool=memcheck
==22877==    --num-callers=yes
==22877==    --leak-check=yes
==22877==    --leak-resolution=high
==22877==    --show-reachable=yes
==22877== Contents of /proc/version:
==22877==   Linux version 2.6.9-11.ELsmp (bhcompile@decompose.build.redhat.com)
(gcc version 3.4.3 20050227 (Red Hat 3.4.3-22)) #1 SMP Fri May 20 18:26:27 EDT
2005
==22877== Reading syms from /home/john/testcase/test (0x8048000)
==22877== Reading syms from /lib/ld-2.3.4.so (0x1B8E4000)
==22877==    object doesn't have any debug info
==22877== Reading syms from /usr/lib/valgrind/stage2 (0XB0000000)
==22877== Reading syms from /lib/ld-2.3.4.so (0xB1000000)
==22877==    object doesn't have any debug info
==22877== Reading syms from /usr/lib/valgrind/vgskin_memcheck.so (0xB7CA9000)
==22877== Reading syms from /lib/tls/libc-2.3.4.so (0xB7ED2000)
==22877==    object doesn't have any debug info
==22877== Reading syms from /lib/libdl-2.3.4.so (0xB7FFB000)
==22877==    object doesn't have any debug info
==22877== Reading suppressions file: /usr/lib/valgrind/default.supp
==22877== REDIRECT soname:libc.so.6(__GI___ernno_location) to
soname:libpthread.so.0(__errno_location)
==22877== REDIRECT soname:libc.so.6(__errno_location) to
soname:libpthread.so.0(__ernno_location)
==22877== REDIRECT soname:libc.so.6(__GI___h_errno_location) to
soname:libpthread.so.0(__h_errno_location)
==22877== REDIRECT soname:libc.so.6(__h_errno_location) to
soname:libpthread.so.0(__h_errno_location)
==22877== REDIRECT soname:libc.so.6(__GI___res_state) to
soname:libpthread.so.0(__res_state)
==22877== REDIRECT soname:libc.so.6(__res_state) to
soname:libpthread.so.0(__res_state)
==22877== REDIRECT soname:libc.so.6(stpcpy) to *vgpreload_memcheck.so*(stpcpy)
==22877== REDIRECT soname:libc.so.6(strnlen) to
*vgpreload_memcheck.so*(strnlen)
==22877== REDIRECT soname:ld-linux.so.2(stpcpy) to
*vgpreload_memcheck.so*(stpcpy)
==22877== REDIRECT soname:ld-linux.so.2(strchr) to
*vgpreload_memcheck.so*(strchr)
==22877== 
==22877== Reading sysm from /usr/lib/valgrind/vg_inject.so (0x1B8FE000)
==22877== Reading syms from /usr/lib/valgrind/vgpreload_memcheck.so
(0x1B901000)
==22877== TRANSLATE: 0x1B8F5EE0 redirected to 0x1B904100
==22877== Reading syms from /usr/lib/valgrind/libpthread.so (0x1B908000)
==22877== Reading syms from /usr/lib/libstdc++.so.6.0.3 (0x26E000)
==22877==    object doesn't have a symbol table
==22877==    object doesn't have any debug info
==22877== Reading syms from /lib/tls/libm-2.3.4.so (0xC7D000)
==22877==    object doesn't have any debug info
==22877== Reading syms from /lib/libgcc_s-3.4.3-20050228.so.1 (0x244000)
==22877==    object doesn't have a symbol table
==22877==    object doesn't have any debug info
==22877== Reading syms from /lib/tls/libc-2.3.4.so (0xB52000)
==22877==    object doesn't have any debug info
==22877== Reading syms from /lib/libdl-2.3.4.so (0xCA2000)
==22877==    object doesn't have any debug info
==22877== TRANSLATE: 0x1B8E47A0 redirected to 0x52BFF040
This is a message==22877== TRANSLATE: 0xBB5E80 redirected to 0x1B9048F8

==22877== TRANSLATE: 0xBB3DB0 redirected to 0x1B904E24
==22877== 
==22877== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 18 from 1)
--22877-- 
--22877-- supp:   18 dl_relocate_object/dl_main
==22877== malloc/free: in use at exit: 208 bytes in 2 blocks.
==22877== malloc/free: 2 allocs, 0 frees, 208 bytes allocated
==22877== 
==22877== searching for pointers to 2 not-freed blocks
==22877== checked 2579704 bytes.
==22877== 
==22877== 8 bytes in 1 block are still reachable in loss record 1 of 2
==22877==    at 0x1B904984: malloc (vg_replace_malloc.c:131)
==22877==    by 0x30D490: __cxa_get_globals (in /usr/lib/libstdc++.so.6.0.3)
==22877==    by 0x30D1FE: std::uncaught_exception() (in
/usr/lib/libstdc++.so.6.0.3)
==22877==    by 0x2E40FF: std::basic_ostream<char, std::char_traits<char> >&
std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*) (in /usr/lib/libstdc++.so.6.0.3)
==22877==    by 0x8048817: do_something() (test.cpp:8)
==22877==    by 0x8048856: main (test.cpp:14)
==22877== 
==22877== LEAK SUMMARY
==22877==    definitely lost: 0 bytes in 0 blocks.
==22877==    possibly lost:   0 bytes in 0 blocks.
==22877==    still reachable: 8 bytes in 1 blocks.
==22877==         suppressed: 200 bytes in 1 blocks.
--22877--     TT/TC: 0 tc sectors discarded.
--22877--            3092 tt_fast misses.
--22877-- translate: new     2954 (54637 -> 694058; ratio 127:10)
--22877--            discard 2 (59 -> 840; ratio 142:10).
--22877-- chainings: 1837 chainings, 3 unchainings
--22877-- dispatch:  300000 jumps (bb entries); of them 31427 (10%) unchained.
--22877--            238/3675 major/minor sched events.
--22877-- reg-alloc: 648 t-req-spill, 128140+5538 orig+spill uis,
--22877--            15946 total-reg-rank
--22877--    sanity: 126 cheap, 6 expensive checks.
--22877--    ccalls: 12540 C calls, 54% saves+restores avoided (40424 bytes)
--22877--            17039 args, avg 0.87 setup instrs each (4232 bytes)
--22877--            0% clear the stack (37509 bytes)
--22877--            4925 retvals, 32% of reg-reg movs avoided (3066 bytes)


-- 

loizeaux1 at hotmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |loizeaux1 at hotmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25849


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]