|
From: <an...@cl...> - 2005-07-29 12:29:20
Attachments:
indextoname_test.c
|
Hi Dennis, >At 18:27 27.07.2005, Martin André wrote: >>The problem is that running my program using Valgrind makes the >>if_indextoname function (declared as extern char *if_indextoname (unsigned >>int __ifindex, char *__ifname) __THROW; in net/if.h) return NULL with the >>following error in the output: >> >>==10869== Syscall param ioctl(SIOCGIFNAME) points to unaddressable byte(s) >>==10869== at 0x1B9EF114: ioctl (in /lib/tls/libc-2.3.2.so) >>==10869== by 0x8048478: main (test.c:14) >>==10869== Address 0x2 is not stack"d, malloc"d or (recently) free"d > >You are passing an invalid parameter to the syscall, thus 0 is returned. >Check if the parameters to if_indextoname are valid prior to calling it Yes I've checked and the arguments I pass if_indextoname are valid. As I already said - the call to if_indextoname is part of a program that's running as expected (i.e. returning the name of a network interface) when not run from within Valgrind. Does that mean that the error is inside if_indextoname's implementation? Is it possible to tell Valgrind not to examine this syscall? I am attaching the piece of code I'm using in my test. Martin PS: please CC me in the response as I'm not on the list. |
|
From: Dennis L. <pla...@in...> - 2005-07-29 13:04:41
|
Hi,
I have run your program, and it looks like its definetly a valgrind bug in=
=20
handling of this syscall. The "Address" valgrind is complaining about is=20
the integer parameter for this (set if_index to 9 in your example and=20
valgrind will complain about address 0x9).
The bug can be fixed somehow in changing line 3045 ff of vg_syscalls.c,=20
however I am not quite shure about how this is really correct (personally=20
Id just comment ou the check for memory readability of the index, but=20
probably something else should be checked then) so its probably better to=20
ask someone else on the list for a quick fix, and please file a Bug for=
this.
greets
Dennis
At 14:29 29.07.2005, Martin Andr=E9 wrote:
>Hi Dennis,
>
>>At 18:27 27.07.2005, Martin Andr=E9 wrote:
>>>The problem is that running my program using Valgrind makes the=20
>>>if_indextoname function (declared as extern char *if_indextoname=20
>>>(unsigned int __ifindex, char *__ifname) __THROW; in net/if.h) return=20
>>>NULL with the following error in the output:
>>>
>>>=3D=3D10869=3D=3D Syscall param ioctl(SIOCGIFNAME) points to=
unaddressable byte(s)
>>>=3D=3D10869=3D=3D at 0x1B9EF114: ioctl (in /lib/tls/libc-2.3.2.so)
>>>=3D=3D10869=3D=3D by 0x8048478: main (test.c:14)
>>>=3D=3D10869=3D=3D Address 0x2 is not stack"d, malloc"d or (recently)=
free"d
>>
>>You are passing an invalid parameter to the syscall, thus 0 is returned.=
=20
>>Check if the parameters to if_indextoname are valid prior to calling it
>
>Yes I've checked and the arguments I pass if_indextoname are valid. As I=20
>already said - the call to if_indextoname is part of a program that's=20
>running as expected (i.e. returning the name of a network interface) when=
=20
>not run from within Valgrind. Does that mean that the error is inside=20
>if_indextoname's implementation? Is it possible to tell Valgrind not to=20
>examine this syscall?
>
>I am attaching the piece of code I'm using in my test.
>
>Martin
>
>PS: please CC me in the response as I'm not on the list.
>
>
>#include <stdio.h>
>#include <stdlib.h>
>#include <string.h>
>#include <net/if.h>
>
>int main()
>{
> unsigned int if_index =3D 2;
> char * if_name =3D NULL;
>
> if_name =3D malloc(IF_NAMESIZE * sizeof(char));
> memset(if_name, 0, IF_NAMESIZE);
> if_indextoname(if_index, if_name);
>
> printf("Interface %d is %s\n", if_index, if_name);
>
> free(if_name);
>
> return 0;
>}
Carpe quod tibi datum est=20
|
|
From: Tom H. <to...@co...> - 2005-07-29 18:43:10
|
In message <42E...@cl...>
Martin André <an...@cl...> wrote:
> Hi Dennis,
>
> >At 18:27 27.07.2005, Martin André wrote:
> >>The problem is that running my program using Valgrind makes the
> >>if_indextoname function (declared as extern char *if_indextoname (unsigned
> >>int __ifindex, char *__ifname) __THROW; in net/if.h) return NULL with the
> >>following error in the output:
> >>
> >>==10869== Syscall param ioctl(SIOCGIFNAME) points to unaddressable byte(s)
> >>==10869== at 0x1B9EF114: ioctl (in /lib/tls/libc-2.3.2.so)
> >>==10869== by 0x8048478: main (test.c:14)
> >>==10869== Address 0x2 is not stack"d, malloc"d or (recently) free"d
> >
> >You are passing an invalid parameter to the syscall, thus 0 is returned.
> >Check if the parameters to if_indextoname are valid prior to calling it
>
> Yes I've checked and the arguments I pass if_indextoname are valid. As I
> already said - the call to if_indextoname is part of a program that's
> running as expected (i.e. returning the name of a network interface)
> when not run from within Valgrind. Does that mean that the error is
> inside if_indextoname's implementation? Is it possible to tell Valgrind
> not to examine this syscall?
This should be fixed now - it was using the value of ifr_index as
the address when trying to test it is was valid.
Tom
--
Tom Hughes (to...@co...)
http://www.compton.nu/
|