| Home | Register | Members | Search | Links |
![]() |
| Thread Tools | Display Modes |
|
|
|
| |
|
step
Guest
Posts: n/a
|
On 7ÔÂ12ÈÕ, ÏÂÎç1ʱ37·Ö, step <fxl...@gmail.com> wrote:
> hi all: > my program use getaddrinfo £¬but when i use valgrind check memory > leak it show getaddrinfo memory leak > code: > int checkAddrType(const char *addr,const char *hostip) > { > struct sockaddr_in ad,*adp; > struct addrinfo hints,*result; > char buf[100]; > > if(inet_pton(PF_INET,addr,&ad.sin_addr)<=0) > { > memset(&hints,0,sizeof(hints)); > hints.ai_family=PF_UNSPEC; > hints.ai_socktype=SOCK_STREAM; > if(getaddrinfo(addr,"www",&hints,&result)!=0) > { > return -1; > } > > adp=(struct sockaddr_in *)result->ai_addr; > inet_ntop(PF_INET,&adp->sin_addr,buf,100); > freeaddrinfo(result); > if(compIp(buf,hostip)==0) > return 2; > return 3; > > } > > if(compIp(addr,hostip)==0) > return 1; > > return 0;} > > test code: > > #include <addressinfo.h> > > int main(int argc,char **argv) > { > > int i; > > for(i=0;i<1000;i++) > { > checkAddrType("www.zju.edu.cn","10.10.8.22"); > } > > return 0; > > } > > valgrind check log: > ==11044== Memcheck, a memory error detector. > ==11044== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et > al. > ==11044== Using LibVEX rev 1606, a library for dynamic binary > translation. > ==11044== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP. > ==11044== Using valgrind-3.2.0-Debian, a dynamic binary > instrumentation framework. > ==11044== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et > al. > ==11044== For more details, rerun with: -v > ==11044== > --11044-- DWARF2 CFI reader: unhandled CFI instruction 0:50 > --11044-- DWARF2 CFI reader: unhandled CFI instruction 0:50 > --11044-- DWARF2 CFI reader: unhandled CFI instruction 0:50 > --11044-- DWARF2 CFI reader: unhandled CFI instruction 0:50 > ==11044== Invalid read of size 4 > ==11044== at 0x40114D0: (within /lib/ld-2.3.6.so) > ==11044== by 0x4004E29: (within /lib/ld-2.3.6.so) > ==11044== by 0x4006B55: (within /lib/ld-2.3.6.so) > ==11044== by 0x400A576: (within /lib/ld-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x400AB31: (within /lib/ld-2.3.6.so) > ==11044== by 0x4193BFB: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x419455A: _dl_open (in /lib/tls/libc-2.3.6.so) > ==11044== by 0x4195AEC: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x4195C4D: __libc_dlopen_mode (in /lib/tls/ > libc-2.3.6.so) > ==11044== Address 0x41C6E50 is 24 bytes inside a block of size 27 > alloc'd > ==11044== at 0x401C4A1: malloc (vg_replace_malloc.c:149) > ==11044== by 0x4006DF0: (within /lib/ld-2.3.6.so) > ==11044== by 0x400A576: (within /lib/ld-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x400AB31: (within /lib/ld-2.3.6.so) > ==11044== by 0x4193BFB: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x419455A: _dl_open (in /lib/tls/libc-2.3.6.so) > ==11044== by 0x4195AEC: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x4195C4D: __libc_dlopen_mode (in /lib/tls/ > libc-2.3.6.so) > ==11044== by 0x41702ED: __nss_lookup_function (in /lib/tls/ > libc-2.3.6.so) > ==11044== > ==11044== Invalid read of size 4 > ==11044== at 0x40114B9: (within /lib/ld-2.3.6.so) > ==11044== by 0x4004E29: (within /lib/ld-2.3.6.so) > ==11044== by 0x4006B55: (within /lib/ld-2.3.6.so) > ==11044== by 0x400A576: (within /lib/ld-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x400AB31: (within /lib/ld-2.3.6.so) > ==11044== by 0x4193BFB: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x419455A: _dl_open (in /lib/tls/libc-2.3.6.so) > ==11044== by 0x4195AEC: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x4195C4D: __libc_dlopen_mode (in /lib/tls/ > libc-2.3.6.so) > ==11044== Address 0x41C717C is 20 bytes inside a block of size 22 > alloc'd > ==11044== at 0x401C4A1: malloc (vg_replace_malloc.c:149) > ==11044== by 0x4006DF0: (within /lib/ld-2.3.6.so) > ==11044== by 0x400A576: (within /lib/ld-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x400AB31: (within /lib/ld-2.3.6.so) > ==11044== by 0x4193BFB: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x419455A: _dl_open (in /lib/tls/libc-2.3.6.so) > ==11044== by 0x4195AEC: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x4195C4D: __libc_dlopen_mode (in /lib/tls/ > libc-2.3.6.so) > ==11044== by 0x41702ED: __nss_lookup_function (in /lib/tls/ > libc-2.3.6.so) > ==11044== > ==11044== Conditional jump or move depends on uninitialised value(s) > ==11044== at 0x4009313: (within /lib/ld-2.3.6.so) > ==11044== by 0x4193EA9: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x419455A: _dl_open (in /lib/tls/libc-2.3.6.so) > ==11044== by 0x4195AEC: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x4195C4D: __libc_dlopen_mode (in /lib/tls/ > libc-2.3.6.so) > ==11044== by 0x41702ED: __nss_lookup_function (in /lib/tls/ > libc-2.3.6.so) > ==11044== by 0x417048E: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x4171DCF: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x417669D: getservbyname_r (in /lib/tls/libc-2.3.6.so) > ==11044== by 0x4144C42: (within /lib/tls/libc-2.3.6.so) > ==11044== > ==11044== Conditional jump or move depends on uninitialised value(s) > ==11044== at 0x4008FB0: (within /lib/ld-2.3.6.so) > ==11044== by 0x4193EA9: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x419455A: _dl_open (in /lib/tls/libc-2.3.6.so) > ==11044== by 0x4195AEC: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x4195C4D: __libc_dlopen_mode (in /lib/tls/ > libc-2.3.6.so) > ==11044== by 0x41702ED: __nss_lookup_function (in /lib/tls/ > libc-2.3.6.so) > ==11044== by 0x417048E: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x4171DCF: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x417669D: getservbyname_r (in /lib/tls/libc-2.3.6.so) > ==11044== by 0x4144C42: (within /lib/tls/libc-2.3.6.so) > ==11044== > ==11044== Invalid read of size 4 > ==11044== at 0x40114D0: (within /lib/ld-2.3.6.so) > ==11044== by 0x4004E29: (within /lib/ld-2.3.6.so) > ==11044== by 0x4006B55: (within /lib/ld-2.3.6.so) > ==11044== by 0x4193B9F: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x419455A: _dl_open (in /lib/tls/libc-2.3.6.so) > ==11044== by 0x4195AEC: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x4195C4D: __libc_dlopen_mode (in /lib/tls/ > libc-2.3.6.so) > ==11044== by 0x41702ED: __nss_lookup_function (in /lib/tls/ > libc-2.3.6.so) > ==11044== by 0x4145E36: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x4146855: getaddrinfo (in /lib/tls/libc-2.3.6.so) > ==11044== Address 0x41C8CC0 is 24 bytes inside a block of size 25 > alloc'd > ==11044== at 0x401C4A1: malloc (vg_replace_malloc.c:149) > ==11044== by 0x4006DF0: (within /lib/ld-2.3.6.so) > ==11044== by 0x4193B9F: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x419455A: _dl_open (in /lib/tls/libc-2.3.6.so) > ==11044== by 0x4195AEC: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x400BA5E: (within /lib/ld-2.3.6.so) > ==11044== by 0x4195C4D: __libc_dlopen_mode (in /lib/tls/ > libc-2.3.6.so) > ==11044== by 0x41702ED: __nss_lookup_function (in /lib/tls/ > libc-2.3.6.so) > ==11044== by 0x4145E36: (within /lib/tls/libc-2.3.6.so) > ==11044== by 0x4146855: getaddrinfo (in /lib/tls/libc-2.3.6.so) > ==11044== by 0x80486FE: checkAddrType (addressinfo.c:71) > ==11044== > ==11044== ERROR SUMMARY: 13 errors from 5 contexts (suppressed: 17 > from 1) > ==11044== malloc/free: in use at exit: 26,000 bytes in 1,000 blocks. > ==11044== malloc/free: 17,067 allocs, 16,067 frees, 3,637,948 bytes > allocated. > ==11044== For counts of detected errors, rerun with: -v > ==11044== searching for pointers to 1,000 not-freed blocks. > ==11044== checked 92,612 bytes. > ==11044== > ==11044== > ==11044== 26,000 bytes in 1,000 blocks are definitely lost in loss > record 1 of 1 > ==11044== at 0x401C4A1: malloc (vg_replace_malloc.c:149) > ==11044== by 0x439A5BF: ??? > ==11044== by 0x439A656: ??? > ==11044== by 0x4373483: ??? > ==11044== by 0x436C8B4: ??? > ==11044== by 0x436CE92: ??? > ==11044== by 0x42C972D: ??? > ==11044== by 0x42C9817: ??? > ==11044== by 0x42C8F95: ??? > ==11044== by 0x42C91D4: ??? > ==11044== by 0x41765DB: getservbyname_r (in /lib/tls/libc-2.3.6.so) > ==11044== by 0x4144C42: (within /lib/tls/libc-2.3.6.so) > ==11044== > ==11044== LEAK SUMMARY: > ==11044== definitely lost: 26,000 bytes in 1,000 blocks. > ==11044== possibly lost: 0 bytes in 0 blocks. > ==11044== still reachable: 0 bytes in 0 blocks. > ==11044== suppressed: 0 bytes in 0 blocks. i change the "www" to NULL ,it ok , why??? |
|
|
|
|
|||
|
|||
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| AFD.sys Memory Leak | wade | Windows Networking | 0 | 02-01-2008 02:57 PM |
| Nonpaged Pool Memory Leak | kokofoot | Windows Networking | 1 | 04-29-2006 05:51 PM |
| SNMP memory leak | mkirros | Windows Networking | 1 | 05-11-2005 04:11 AM |
| Wireless Zero Configuration Memory Leak?? | Rickschultz1 | Wireless Networks | 2 | 01-19-2005 10:26 PM |
| Slow memory leak? | Captain Dondo | Linux Networking | 0 | 10-02-2003 08:41 AM |
Forum Software Powered by vBulletin®, Copyright Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc. |



Linear Mode

