getaddrinfo memory leak

前端 未结 3 1676
我寻月下人不归
我寻月下人不归 2020-12-17 10:32

I have this code for getting information about IPv4 address:

struct addrinfo hints, *info = NULL;
char addr4[INET_ADDRSTRLEN];

memset(&hints, 0, sizeof(h         


        
相关标签:
3条回答
  • 2020-12-17 11:11

    Looking a bit the gblic, it's about object catching in case of ipv6 (look 249 line).

    As other members have explained, "still reachable" is not an error itself, but it may hide some buggy situations. In this case it's not a problem, just a warning about something that could hide something nasty.

    This warning has also been reported to redhat

    The reason of the warning for google and not for ubuntu it's beacause google has ipv6 deployed on its servers and ubuntu not, and then the catching is not performed. You can check it with:

    nslookup -q=AAAA www.google.com
    nslookup -q=AAAA www.ubuntu.com
    
    0 讨论(0)
  • 2020-12-17 11:18

    It says "still reachable". That probably means that the library allocated some memory for a cache or something like that and doesn't want to free it. You can safely ignore it or at least it needs more analysis than just saying it's a memory leak.

    Why there's a difference between different hosts is anyones guess. Probably because different name servers require different type of work.

    0 讨论(0)
  • 2020-12-17 11:25

    This may not be a memory leak (technically it is, but you shouldn't worry about it) sometimes libraries allocate memory the first time a function is called for subsequent calls. you can have valgrind suppress those errors if you want.

    From the FAQ:

    "still reachable" means your program is probably ok -- it didn't free some memory it could have. This is quite common and often reasonable. Don't use --show-reachable=yes if you don't want to see these reports.

    0 讨论(0)
提交回复
热议问题