Python/Tkinter/tk crash [long]

Pedro Rodriguez pedro_rodriguez at club-internet.fr
Sat Aug 16 12:26:48 EDT 2003


On Thu, 14 Aug 2003 09:10:22 +0000, Eric Brunel wrote:

> Hi all,
> 
> I was creating a Tkinter widget in the style of the reversed tabs below Excel 
> worksheets and I stepped in a serious problem: the code I made makes python 
> crash with a seg fault, bus error or X11 BadGC error on both Solaris (2.6 and 
> 2.7) and Linux (Mandrake 8.0); it doesn't crash on Windows. I tried to simplify 
> the script, but I couldn't reproduce the crash with a simpler code. So the code 
> below is somewhat long; sorry for that.
> 
> To make it crash, just run the script and click on a tab. It usually crashes at 
> the first click, but you may have to play a bit with the tabs. I tried to run 
> Python through gdb to see where the crash happens, but it seems to be quite 
> random. Maybe a memory corruption?
> 
> There's a simple workaround, but with drawbacks: at the beginning of the 
> __update method, if I do not destroy and re-create the Canvas, but simply empty 
> its contents, the script works. But it keeps the commands declared created at 
> the tcl level for the former bindings, so it silently eats up memory.
> 

As far as I understand, the __changeTab method is called when an event
occurs on the __tabsCanvas. But one of the first actions of the __update
method (which is called by __changeTab) is to destroy the __tabsCanvas
object. 

So DURING the callback call you are destroying the object to which the
callback is bound. I wonder if this is the cause of the blow up at the
return of the callback (it may depend on how  the memory is reallocated
on different systems).

Just my 0.02 euro guess

-- 
Pedro




More information about the Python-list mailing list