Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[getaddrinfo] Mudflap violation reason

86 views
Skip to first unread message

Maciej Labanowicz

unread,
Jan 25, 2013, 7:53:53 AM1/25/13
to
Hi,

I have simple code that invokes mudflap violation:

$ gawk '{printf("%02u: %s\n", NR, $0);}' test.c
01: #include <stdio.h>
02: #include <stdlib.h>
03: #include <sys/types.h>
04: #include <sys/socket.h>
05: #include <netdb.h>
06: int main(void) {
07: struct addrinfo * info = NULL;
08: if (!getaddrinfo("127.0.0.1", "tftp", NULL, &info)) {
09: printf("OK\r\n");
10: printf("%d\r\n", info->ai_family);
11: freeaddrinfo(info);
12: }
13: else {
14: printf("ERR\r\n");
15: }
16: return EXIT_SUCCESS;
17: }

$ gcc --version
gcc (Ubuntu/Linaro 4.7.2-11precise2) 4.7.2

$ gcc test.c -fmudflap -lmudflap -o a.out

$ echo ":${MUDFLAP_OPTIONS}:"
:-check-initialization:

$ ./a.out
OK
*******
mudflap violation 1 (check/read): time=1359118134.862918 ptr=0x9cc29c8
size=8
pc=0xb764c42e location=`test.c:10:11 (main)'
/usr/lib/i386-linux-gnu/libmudflap.so.0(__mf_check+0x3e)
[0xb764c42e]
./a.out(main+0xd7) [0x8048923]
/usr/lib/i386-linux-gnu/libmudflap.so.0(__wrap_main+0x4a)
[0xb764bbaa]
Nearby object 1: checked region begins 0B into and ends 7B into
mudflap object 0x9cc2a20: name=`malloc region'
bounds=[0x9cc29c8,0x9cc29f7] size=48 area=heap check=1r/0w liveness=1
alloc time=1359118134.862711 pc=0xb764bb4e
/usr/lib/i386-linux-gnu/libmudflap.so.0(__mf_register+0x3e)
[0xb764bb4e]
/usr/lib/i386-linux-gnu/libmudflap.so.0(__real_malloc+0xc5)
[0xb764c8d5]
/lib/i386-linux-gnu/libc.so.6(+0xc7221) [0xb7561221]
/lib/i386-linux-gnu/libc.so.6(getaddrinfo+0xdd) [0xb7562fdd]
Nearby object 2: checked region begins 0B into and ends 7B into
mudflap dead object 0x9cbca98: name=`malloc region'
bounds=[0x9cc29c8,0x9cc2b27] size=352 area=heap check=0r/0w liveness=0
alloc time=1359118134.860663 pc=0xb764bb4e
/usr/lib/i386-linux-gnu/libmudflap.so.0(__mf_register+0x3e)
[0xb764bb4e]
/usr/lib/i386-linux-gnu/libmudflap.so.0(__real_malloc+0xc5)
[0xb764c8d5]
/lib/i386-linux-gnu/libc.so.6(+0x65d18) [0xb74ffd18]
/lib/i386-linux-gnu/libc.so.6(fopen+0x2b) [0xb74ffdeb]
dealloc time=1359118134.860809 pc=0xb764b6e6
/usr/lib/i386-linux-gnu/libmudflap.so.0(__mf_unregister+0x36)
[0xb764b6e6]
/usr/lib/i386-linux-gnu/libmudflap.so.0(free+0x98) [0xb764cec8]
/lib/i386-linux-gnu/libc.so.6(fclose+0x154) [0xb74ff424]
/lib/i386-linux-gnu/libnss_files.so.2(+0x3a71) [0xb746ba71]
number of nearby objects: 2
2

Is there an issue in the code ?

Regards

--
Maciej Labanowicz

Richard Kettlewell

unread,
Jan 25, 2013, 9:49:24 AM1/25/13
to
Maciej Labanowicz <m.laba...@gmail.com> writes:
> Is there an issue in the code ?

No. Mudflap doesn't know that getaddrinfo() has initialized 'info'.

--
http://www.greenend.org.uk/rjk/

Martin Musatov

unread,
Feb 11, 2013, 6:55:56 AM2/11/13
to
On Jan 25, 2:49 pm, Richard Kettlewell <r...@greenend.org.uk> wrote:
> Maciej Labanowicz <m.labanow...@gmail.com> writes:
> > Is there an issue in the code ?
>
> No.  Mudflap doesn't know that getaddrinfo() has initialized 'info'.
>
> --http://www.greenend.org.uk/rjk/

greenend.announce Announcements of unpleasant medical complaints
greenend.commits Commit messages from SGO software projects
greenend.config greenend.* administrivia
greenend.misc Unpleasant medical complaints
greenend.relativity.private.rsvp Party invite replies (Relativity).
greenend.system cron barfmail
greenend.test Tests for unpleasant medical complaints
greenend.vpn Private networking among the SGO and associates
0 new messages