mudflap and socket()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I would like to know why mudflap says there is an error on line 22. Is
it a false positive ?

(I am using Debian squeeze, gcc 4.4.5 and eglibc 2.11.2)



myuser@linux:~/Desktop$ export MUDFLAP_OPTIONS="-mode-check
-viol-abort -internal-checking -print-leaks -check-initialization
-verbose-violations -crumple-zone=32"
myuser@linux:~/Desktop$ gcc -std=c99 -D_POSIX_C_SOURCE=200112L -ggdb3
-O0 -fmudflap -funwind-tables -lmudflap -rdynamic myprogram.c
myuser@linux:~/Desktop$ ./a.out
*******
mudflap violation 1 (check/read): time=1303221485.951128 ptr=0x70cf10 size=16
pc=0x7fc51c9b1cc1 location=`myprogram.c:22:18 (main)'
      /usr/lib/libmudflap.so.0(__mf_check+0x41) [0x7fc51c9b1cc1]
      ./a.out(main+0x113) [0x400b97]
      /lib/libc.so.6(__libc_start_main+0xfd) [0x7fc51c665c4d]
Nearby object 1: checked region begins 0B into and ends 15B into
mudflap object 0x70cf90: name=`malloc region'
bounds=[0x70cf10,0x70cf5b] size=76 area=heap check=1r/0w liveness=1
alloc time=1303221485.949881 pc=0x7fc51c9b1431
      /usr/lib/libmudflap.so.0(__mf_register+0x41) [0x7fc51c9b1431]
      /usr/lib/libmudflap.so.0(__wrap_malloc+0xd2) [0x7fc51c9b2a12]
      /lib/libc.so.6(+0xaada5) [0x7fc51c6f1da5]
      /lib/libc.so.6(getaddrinfo+0x162) [0x7fc51c6f4782]
Nearby object 2: checked region begins 640B before and ends 625B before
mudflap dead object 0x70d3f0: name=`malloc region'
bounds=[0x70d190,0x70d3c7] size=568 area=heap check=0r/0w liveness=0
alloc time=1303221485.950059 pc=0x7fc51c9b1431
      /usr/lib/libmudflap.so.0(__mf_register+0x41) [0x7fc51c9b1431]
      /usr/lib/libmudflap.so.0(__wrap_malloc+0xd2) [0x7fc51c9b2a12]
      /lib/libc.so.6(+0x6335b) [0x7fc51c6aa35b]
      /lib/libc.so.6(+0xac964) [0x7fc51c6f3964]
dealloc time=1303221485.950696 pc=0x7fc51c9b0fe6
      /usr/lib/libmudflap.so.0(__mf_unregister+0x36) [0x7fc51c9b0fe6]
      /usr/lib/libmudflap.so.0(__real_free+0xa0) [0x7fc51c9b2f40]
      /lib/libc.so.6(fclose+0x14d) [0x7fc51c6a9a1d]
      /lib/libc.so.6(+0xacc1a) [0x7fc51c6f3c1a]
number of nearby objects: 2
Aborted (core dumped)
myuser@linux:~/Desktop$



#include <stdio.h>
#include <sys/socket.h>
#include <netdb.h>

int main(void)
{
    struct addrinfo hints, *result;
    hints.ai_flags      = 0;
    hints.ai_family     = AF_UNSPEC;
    hints.ai_socktype   = SOCK_STREAM;
    hints.ai_protocol   = IPPROTO_TCP;
    hints.ai_addrlen    = 0;
    hints.ai_canonname  = NULL;
    hints.ai_addr       = NULL;
    hints.ai_next       = NULL;

    if(getaddrinfo("localhost", "25", &hints, &result) != 0)
    {
        return -1;
    }

    int newsocket = socket(result->ai_family, result->ai_socktype,
result->ai_protocol); // line 22
    if(newsocket == -1)
    {
        freeaddrinfo(result);
        return -2;
    }

    return 0;
}


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux