[New-bugs-announce] [issue39093] tkinter objects garbage collected from non-tkinter thread cause panic and core dump
report at bugs.python.org
Wed Dec 18 21:56:56 EST 2019
New submission from obserience <obserience at 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.
>Tcl_AsyncDelete: async handler deleted by the wrong thread
>Aborted (core dumped)
"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.
title: tkinter objects garbage collected from non-tkinter thread cause panic and core dump
Added file: https://bugs.python.org/file48789/error_case.py
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce