Valgrind warning cleanup...

Dan Kegel dank at kegel.com
Sat May 13 15:01:34 CDT 2006


I was trying to use valgrind-3.1.1 to track down
an OpenOffice crash, and I noticed that current
wine shows errors like this even running notepad:

==8986== Invalid read of size 4
==8986==    at 0x20010C21: (within /lib/ld-2.3.6.so)
...
==8986==    by 0x20189D10: dlopen (in /lib/tls/i686/cmov/libdl-2.3.6.so)
==8986==    by 0x20023CB8: wine_dlopen (loader.c:663)
==8986==    by 0x200248B7: wine_init (loader.c:625)
==8986==    by 0x7BF00F9F: main (main.c:58)
==8986==  Address 0x2018D3A8 is 56 bytes inside a block of size 57 alloc'd
==8986==    at 0x2001C422: malloc (vg_replace_malloc.c:149)
==8986==    by 0x2002463A: first_dll_path (loader.c:201)
==8986==    by 0x20024895: wine_init (loader.c:623)
==8986==    by 0x7BF00F9F: main (main.c:58)

I looked at first_dll_path, but I couldn't see any problem.
On the theory that glibc is reading a bit past the end of the string,
I tried changing the line that does the allocation in question.
Adding one byte cut down the number of those warnings;
adding two bytes didn't help more than adding one;
adding three bytes got rid of the warnings.  Here's the change:

--- libs/wine/loader.c  17 Mar 2006 12:23:52 -0000      1.36
+++ libs/wine/loader.c  13 May 2006 19:56:52 -0000
@@ -199,7 +199,7 @@
     char *p;
     int namelen = strlen( name );

-    context->buffer = malloc( dll_path_maxlen + 2 * namelen +
strlen(ext) + 3 );
+    context->buffer = malloc( dll_path_maxlen + 2 * namelen +
strlen(ext) + 6 );
     context->index = build_dir ? 0 : 3;  /* if no build dir skip all
the build dir magic cases */
     context->name = context->buffer + dll_path_maxlen + namelen + 1;
     context->namelen = namelen + 1;

What do folks think - should we just make the allocation a little bigger to make
valgrind happy?

I'd also like to understand what's causing them, too, though.
- Dan

-- 
Wine for Windows ISVs: http://kegel.com/wine/isv



More information about the wine-devel mailing list