|
From: Christian K. <chr...@si...> - 2007-06-22 14:20:10
|
Hi all,
I use SUSE Linux 10.1 with valgrind 3.2. When I test my program with valgrind I
get the following valgrind error when sending a message over a udp ip socket.
==20943== Syscall param socketcall.sendto(msg) points to uninitialised byte(s)
==20943== at 0x40FF938: sendto (in /lib/libc-2.4.so)
==20943== by 0x804FC66: infospace_action_send_answer
(infospace_common_actions.c:58)
==20943== by 0x804DB00: publish_action_handle_publish (publish_action.c:152)
==20943== by 0x804FD0E: infospace_action_process_request
(infospace_common_actions.c:75)
==20943== by 0x804E568: udp_unicast_server_receive (udp_unicast_server.c:143)
==20943== by 0x416634A: start_thread (in /lib/libpthread-2.4.so)
==20943== by 0x40FE65D: clone (in /lib/libc-2.4.so)
==20943== Address 0x4979ECC is 300 bytes inside a block of size 585 alloc'd
==20943== at 0x40223F0: malloc (in
/usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==20943== by 0x80499BB: meminit (fpga_util.c:160)
==20943== by 0x804DD21: udp_unicast_send_message (udp_unicast_client.c:86)
==20943== by 0x804FC66: infospace_action_send_answer
(infospace_common_actions.c:58)
==20943== by 0x804DB00: publish_action_handle_publish (publish_action.c:152)
==20943== by 0x804FD0E: infospace_action_process_request
(infospace_common_actions.c:75)
==20943== by 0x804E568: udp_unicast_server_receive (udp_unicast_server.c:143)
==20943== by 0x416634A: start_thread (in /lib/libpthread-2.4.so)
==20943== by 0x40FE65D: clone (in /lib/libc-2.4.so)
The command line I use is:
valgrind --tool=memcheck --leak-check=yes --db-attach=yes --verbose
./Debug/FPGA_main 192.168.235.100 192.168.235.255 100
The code snippet where the error is generated can be seen below.
----- 8< --code-------------------------------------
bufflen = meminit ((void**)&buffer,
UUID_SIZE +sizeof (int) +sizeof (long) +
msg.content_size +10,
"udp_unicast_send_message:88");
dm_message_serialize_message (msg, buffer);
gettimeofday (&act_time, NULL);
/* send data */
printf ("sending data %d %lx %d 0 %lx \n\n", sd,
(unsigned long)buffer,
bufflen,
(unsigned long)&remoteServAddr);
rc = sendto (sd, buffer,
bufflen,
0,
(struct sockaddr *) &remoteServAddr,
sizeof (remoteServAddr));
memrelease (buffer, "udp_unicast_send_message:98");
----- 8< --code-------------------------------------
It looks for me as if the send buffer argument points to uninitialized bytes,
but the buffer is allocated correctly as my malloc wrapper prints out.
MEMINIT: allocated 585 bytes at address 0x4979da0 --> called by
udp_unicast_send_message:88
The pointer to buffer points to a memory address 300 bytes before the error
address, but the address in the error (0x4979ECC) is never allocated. So are
there any suggestions what might cause this error?
I hope I could make clear where my problem lies and there is someone out there
who can give me a hint how to fix this error.
all the best and thanks in advance
Christian
|