|
From: Mark L. <lof...@qw...> - 2003-08-26 17:06:51
|
>From: Andreas Oesterhelt
>Subj: Probably OT: Losing memory within gethostbyname_r, inet_ntoa
>Date: 2003-05-08 07:01
>For example, gethostbyname_r is not supposed to do any allocations
>at all (the result structure and scratch buffer are provided by
>the caller). Yet at exit I get lots of these:
...
>Looking closer it seems as if ld was callocing memory for whatever
>use, leaving me with a dynamic allocation that I don't have a pointer
>to to free it. Even stranger: This being listed under "still reachable"
>implies that there is a pointer -- but where?
>
>Also note the oddness of gethostbyname_r@@GLIBC_2.1.2 although the
>application and valgrind were compiled and run on a glibc 2.2.4 system.
I've been working on a project lately that uses getaddrinfo() to resolve
names. This function soon calls gethostbyname2_r which has (it seems)
some of the same issues you are having with gethostbyname_r. In order to
save myself the headaches of seeing these errors repeated every time I
debug my program, I whipped up the following suppression file.
The invalid read scares me a little as it appears to be an off-by-one
read error in strrchr. The memory leaks are more of a nuisance I think,
as the amount of mem leaked remains constant (~2k) regardless of the
number of iterations on gethostbyname2_r.
Mark
--gethost.supp--
###############
## the getaddrinfo() calls gaih_inet() which in turn calls
gethostbyname2_r@@GLIBC_2.1.2
## this suppression file should hide all the errors in the
gethostbyname2_r function.
###############
## based on a glibc-2.2.4/gcc-2.96 setup (RH 7.2)
###############
################
##<---suppress the Invalid read of size 4
################
{
strrchr/_dl_map_object_from_fd(Addr4)
Memcheck:Addr4
fun:strrchr
fun:_dl_map_object_from_fd
}
################
##<---suppress all the memory leaks
################
{
gethostbyname2/malloc/_dl_map_object(Leak)
Memcheck:Leak
fun:malloc
fun:_dl_map_objec*
fun:dl_open_worker
fun:_dl_catch_error
}
{
gethostbyname2/malloc/__res_nsend(Leak)
Memcheck:Leak
fun:malloc
fun:__res_nsend
fun:__res_nquery
fun:__res_nquerydomain
}
{
gethostbyname2/(X)alloc/_dl_new_object(Leak)
Memcheck:Leak
fun:?alloc
fun:_dl_new_object
fun:_dl_map_object_from_fd
fun:_dl_map_object
}
{
gethostbyname2/calloc/_dl_check_map_version(Leak)
Memcheck:Leak
fun:calloc
fun:_dl_check_map_versions
fun:dl_open_worker
fun:_dl_catch_error
}
|