[ENet-discuss] eNet and valgrind.
Espen Overaae
minthos at gmail.com
Sun Feb 24 04:05:04 PST 2008
Valgrind is giving me these warnings:
==26393== Syscall param socketcall.sendmsg(msg.msg_name) points to
uninitialised byte(s)
==26393== at 0x4B3138B: (within /lib64/libpthread-2.5.so)
==26393== by 0x4C5299C: enet_socket_send (unix.c:284)
==26393== by 0x4C5208A: enet_protocol_send_outgoing_commands
(protocol.c:1406)
==26393== by 0x4C52308: enet_host_service (protocol.c:1528)
==26393== Syscall param socketcall.sendmsg(msg.msg_name) points to
uninitialised byte(s)
==26393== at 0x4B3138B: (within /lib64/libpthread-2.5.so)
==26393== by 0x4C5299C: enet_socket_send (unix.c:284)
==26393== by 0x4C5208A: enet_protocol_send_outgoing_commands
(protocol.c:1406)
==26393== by 0x4C5227F: enet_host_service (protocol.c:1500)
==26393== Syscall param socketcall.sendmsg(msg.msg_name) points to
uninitialised byte(s)
==26393== at 0x4B3138B: (within /lib64/libpthread-2.5.so)
==26393== by 0x4C5299C: enet_socket_send (unix.c:284)
==26393== by 0x4C5208A: enet_protocol_send_outgoing_commands
(protocol.c:1406)
==26393== by 0x4C52118: enet_host_flush (protocol.c:1428)
After investigating the cause, it seems the variable sin, used in
msgHdr.msg_name = & sin; at enet_socket_send (unix.c:281)
is the culprit.
http://beej.us/guide/bgnet/output/html/multipage/sockaddr_inman.html
has this to say about it:
> #include <netinet/in.h>
>
> struct sockaddr_in {
> short sin_family; // e.g. AF_INET
> unsigned short sin_port; // e.g. htons(3490)
> struct in_addr sin_addr; // see struct in_addr, below
> char sin_zero[8]; // zero this if you want to
> };
>
> struct in_addr {
> unsigned long s_addr; // load with inet_aton()
> };
and especially:
> There's also this sin_zero field which some people claim must be set to zero.
> Other people don't claim anything about it (the Linux documentation doesn't
> even mention it at all), and setting it to zero doesn't seem to be actually
> necessary. So, if you feel like it, set it to zero using memset().
Setting sin.sin_zero to zero makes the problem go away.
Espen Overaae
More information about the ENet-discuss
mailing list