New submission from obserience <obserie...@gmail.com>:

All tkinter objects have a reference to the TCL interpreter object "self.tk". 
The current cleanup code does not remove these when a widget is destroyed.

Garbage collection of the TCL interpreter object occurs only after all gui 
objects are garbage collected. This may  be triggered from another thread 
causing TCL to panic and trigger a core dump.

Error message:
>Tcl_AsyncDelete: async handler deleted by the wrong thread
>Aborted (core dumped)

Adding:
"self.tk = None"
to the end of Misc.destroy() (tkinter/__init__.py line:439) should fix this by 
removing these reference when widgets are destroyed. (Note:destroy is recursive 
on the widget tree and called on the root object when a Tkinter GUI exits)

I can't see any problem with removing the interpreter object from a widget when 
it is destroyed. There doesn't seem to be any way to reassign a widget to a new 
parent so this shouldn't affect anything.

Doing this makes it safe(r) to use tkinter from a non-main thread since if the 
GUI cleans up properly no "landmines" are left to cause a crash when garbage 
collected in the wrong thread.

----------
components: Tkinter
files: error_case.py
messages: 358652
nosy: obserience
priority: normal
severity: normal
status: open
title: tkinter objects garbage collected from non-tkinter thread cause panic 
and core dump
type: crash
Added file: https://bugs.python.org/file48789/error_case.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39093>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to