Valgrind and structs with holes
Dan Kegel
dank at kegel.com
Wed Oct 31 17:59:48 CDT 2007
Valgrind is a great tool, but if there's a struct with a hole in
it, and we write that struct to a socket (say, to send it to the
server), valgrind will likely complain that the hole is uninitialized.
For instance, the warning
==3415== Syscall param writev(vector[1]) points to uninitialised byte(s)
==3415== at 0x40007F2: (within /lib/ld-2.6.1.so)
==3415== by 0x4412E24: wine_server_call (server.c:244)
==3415== by 0x43EBA73: server_ioctl_file (file.c:1010)
==3415== by 0x43EC570: NtFsControlFile (file.c:1223)
==3415== by 0x45394C1: WaitNamedPipeW (sync.c:1298)
==3415== by 0x453963B: WaitNamedPipeA (sync.c:1225)
==3415== by 0x46490B5: test_CreateNamedPipe (pipe.c:97)
in kernel32/tests/sync.c can be silenced either by appeasing Valgrind
with a patch like
--- a/dlls/kernel32/sync.c
+++ b/dlls/kernel32/sync.c
@@ -1285,6 +1285,12 @@ BOOL WINAPI WaitNamedPipeW (LPCWSTR name, DWORD nTimeOut)
return FALSE;
}
+ /* FILE_PIPE_WAIT_FOR_BUFFER has a hole after boolean TimeoutSpecified.
+ * Clear the hole so valgrind doesn't get upset about uninitialized bytes.
+ * No need to zero Name[1...], which is initialized ok later.
+ */
+ memset(pipe_wait, 0, sizeof(FILE_PIPE_WAIT_FOR_BUFFER));
or by using a suppression like
{
wine_struct_hole_FILE_PIPE_WAIT_FOR_BUFFER
Memcheck:Param
writev(vector[1])
obj:*
fun:wine_server_call
fun:server_ioctl_file
fun:NtFsControlFile
fun:WaitNamedPipeW
}
Alexandre, which approach would you prefer? If you say #1, I'll eat my hat.
- Dan
--
Wine for Windows ISVs: http://kegel.com/wine/isv
More information about the wine-devel
mailing list