Valgrind and structs with holes

Alexandre Julliard julliard at winehq.org
Fri Nov 2 04:18:01 CDT 2007


"Dan Kegel" <dank at kegel.com> writes:

> 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.

The same structure can be passed directly from the application, where
you couldn't add a memset anyway, so yes suppressing the warning seems
like the way to go.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list