Title: _tkinter PythonCmd fails to acquire GIL
Type: crash Stage: patch review
Components: Tkinter, Windows Versions:
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: paul.moore, serhiy.storchaka, speleo3, steve.dower, tim.golden, zach.ware
Priority: normal Keywords: patch

Created on 2020-03-26 12:16 by speleo3, last changed 2020-03-28 22:46 by terry.reedy.

File name Uploaded Description Edit speleo3, 2020-03-26 12:16 Minimal example
Pull Requests
URL Status Linked Edit
PR 19178 open speleo3, 2020-03-26 16:18
Messages (1)
msg365064 - (view) Author: Thomas Holder (speleo3) * Date: 2020-03-26 12:16
The attached demo application runs a Tkinter GUI and a PyQt GUI in the same thread. PyQt owns the main loop and keeps updating the Tkinter instance by calling `update()`.

On Windows, when binding a "<Configure>" event, resizing the Tk window will lead to a crash:

Fatal Python error: PyEval_RestoreThread: NULL tstate

Current thread 0x00001f1c (most recent call first):
  File "", line 50 in <module>

This crash happens in `_tkinter.c` in `PythonCmd` inside the `ENTER_PYTHON` macro.

The issue can be fixed by using `PyGILState_Ensure` and `PyGILState_Release` instead of the `ENTER_PYTHON` macro inside the `PythonCmd` function.
Date User Action Args
2020-03-28 22:46:44terry.reedysetnosy: + serhiy.storchaka
2020-03-26 16:18:11speleo3setkeywords: + patch
stage: patch review
pull_requests: + pull_request18538
2020-03-26 12:16:09speleo3create