开发者

gethostbyname() and valgrind

开发者 https://www.devze.com 2022-12-24 16:51 出处:网络
I keep getting this error whenever I call gethostbyname() in my C code. ==7983== Invalid read of size 1

I keep getting this error whenever I call gethostbyname() in my C code.

==7983== Invalid read of size 1
==7983==    at 0x412AB2C: ____strtoul_l_internal (strtol_l.c:298)
==7983==    by 0x412A46F: strtoul (strtol.c:110)
==7983==    by 0x41D427E: inet_aton (inet_addr.c:143)
==7983==    by 0x41开发者_如何学CD8FF3: __nss_hostname_digits_dots (digits_dots.c:144)
==7983==    by 0x41DD0F9: gethostbyname (getXXbyYY.c:109)
==7983==    by 0x804BE6F: connexion_function (in  ***************)
==7983==    by 0x8049A8F: main (in ***************)

Any ideas ? Thanks,


It may be related to the fact that gethostbyname is non-reentrant and returns an object that is shared by all threads. You should probably use getaddrinfo and freeaddrinfo in lieu of gethostbyname.

0

精彩评论

暂无评论...
验证码 换一张
取 消