Wine leaking GDI handles?

Jon Griffiths jon_p_griffiths at yahoo.com
Sun Aug 1 03:53:19 CDT 2004


Hi,

I am trying to track down some GDI leaks in a large application I am
porting. To make things easier I added logging to GDI_AllocObject and
GDI_FreeObject in order to find mismatches at program termination,
and hacked a script to find allocations that weren't deallocated. The
patch to dlls/gdi/gdiobj.c and the script used are both attached
below.

My first question is; Is this a valid approach to tracking leaks, or
are some GDI objects deallocated in another way? i.e. Should there be
a GDI_FreeObject call for every GDI_AllocObject call or not?

I run this analysis by setting WINEDEBUG="+all" and executing my app
redirecting the results to a file. I then run the matching script to
generate a list of addresses from GDI_AllocObject that have no
corresponding GDI_FreeObject, along with the line number in the trace
that the allocation occurred.

This produced a rather overwhelming list which has thus far enabled
me to find several application bugs causing leaks. However
investigating several of the calls makes me suspect that Wine itself
may have some leaks.

If you follow the directions above against Wines clock.exe it lists
here 121 unmatched deallocations (winver has 126). Some of these are
for things like stock objects which arguably aren't very important,
since they are only created once. But it appears that window
creation/destruction may have leaks which is of definite concern here
since my app creates many windows while generating screens on
the fly (I see in my app that when GetDC is called for the first time
on a window, causing a CreateDCW call, a region is leaked, or at
least thats what it looks like to me).

I seems a good idea to attempt to diagnose the leaks on a simple
program like clock/winver before trying a more complicated app. Could
someone with more experience in GDI verify that these leaks are
genuine? I am a little lost amongst the GDI/user code...

Thanks,
Jon

p.s. The script below does not handle GDI realloc, but I have yet to
see it in any of my traces yet.

=====
"Don't wait for the seas to part, or messiahs to come;
 Don't you sit around and waste this chance..." - Live

jon_p_griffiths at yahoo.com


		
__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdiobj.diff
Type: text/x-diff
Size: 1690 bytes
Desc: gdiobj.diff
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20040801/998c72f0/gdiobj.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: find_gdi_mismatch.pl
Type: application/x-perl
Size: 825 bytes
Desc: find_gdi_mismatch.pl
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20040801/998c72f0/find_gdi_mismatch.bin


More information about the wine-devel mailing list