Tk Source Code

View Ticket
Login
Ticket UUID: 1708823
Title: Wish crash on Windows XP when trying to free a color
Type: Bug Version: obsolete: 8.4.12
Submitter: nobody Created on: 2007-04-27 15:15:52
Subsystem: 29. Colormaps and Visuals Assigned To: hobbs
Priority: 5 Medium Severity:
Status: Open Last Modified: 2007-09-23 21:57:39
Resolution: None Closed By:
    Closed on:
Description:
On Windows XP, Wish sometimes crashes after showing a dialog box stating "Tried to free a color that isn't allocated.".

For me, this happens whilst running a Tk application when another application (e.g., a game) takes over the full screen and changes screen resolution (and probably screen color mode).

Other users have seen this as well seemingly from time to time. Refer, e.g., to http://www.amsn-project.net/forums/viewtopic.php?t=584.

This might well be a reoccurrence of bug #570748 (http://sourceforge.net/tracker/index.php?func=detail&aid=570748&group_id=12997&atid=112997).

Regards,
Sebastian
User Comments: yegord added on 2007-09-23 21:57:39:
Logged In: YES 
user_id=1285218
Originator: NO

Confirm for 8.4.15 and today's 8.5beta.

If we call XAllocColor in non-palette mode, than switch to palette mode and call XFreeColors, the latter will free resources, which were never allocated. :-)

Again, we get a memory leak in opposite case.

http://www.vsi.ru/~yegor/files/tkpatch/tkWinColor.c (patched)
http://www.vsi.ru/~yegor/files/tkpatch/tkWinColor.c.ORIG
http://www.vsi.ru/~yegor/files/tkpatch/tkWinColor.c.diff

Probably, not an elegant patch, but works for me.

yegord added on 2007-09-23 21:57:12:
Logged In: YES 
user_id=1285218
Originator: NO

Confirm for 8.4.15 and today's 8.5beta.

If we call XAllocColor in non-palette mode, than switch to palette mode and call XFreeColors, the latter will free resources, which were never allocated. :-)

Again, we get a memory leak in opposite case.

http://www.vsi.ru/~yegor/files/tkpatch/tkWinColor.c (patched)
http://www.vsi.ru/~yegor/files/tkpatch/tkWinColor.c.ORIG
http://www.vsi.ru/~yegor/files/tkpatch/tkWinColor.c.diff

Probably, not an elegant patch, but works for me.