spyoungtech / FreeSimpleGUI

The free-forever GUI library
GNU Lesser General Public License v3.0
377 stars 49 forks source link

Segmentation fault on MacOS 14.5 / Apple Silicon with Python 3.12.5 and FreeSimpleGUI 5.1.1 #32

Open eric-pfi opened 3 months ago

eric-pfi commented 3 months ago

I have a FreeSimpleGUI front end for a plotting utility; there is a button on the FreeSimpleGUI window that renders a plot with matplotlib show(). After closing the plot window (when show() exits), I'm getting a segmentation fault.

I can invoke the same plot via command line switches and bypass any FreeSimpleGUI rendering. In that case, after I close the show() window, no segmentation fault.

I add a faulthandler.enable() before the show(), and got this stack trace for the segmentation fault:

Fatal Python error: Segmentation fault

Current thread 0x00000001f3454c00 (most recent call first):
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/tkinter/__init__.py", line 1505 in mainloop
  File "/Users/elw/Development/brewmonitor-python-toolkit/.venv/lib/python3.12/site-packages/PySimpleGUI.py", line 11263 in _read
  File "/Users/elw/Development/brewmonitor-python-toolkit/.venv/lib/python3.12/site-packages/PySimpleGUI.py", line 11134 in read
  File "/Users/elw/Development/brewmonitor-python-toolkit/pfi/tools/fplot.py", line 414 in fplot_ui
  File "/Users/elw/Development/brewmonitor-python-toolkit/pfi/tools/fplot.py", line 123 in fplot_cli
  File "/Users/elw/Development/brewmonitor-python-toolkit/pfi/tools/fplot.py", line 570 in <module>
  File "<frozen runpy>", line 88 in _run_code
  File "<frozen runpy>", line 198 in _run_module_as_main

I tried PySimpleGUI-4-foss, and had the same behavior, if that helps. Matplotlib version is the most current (3.9.1.post1), but it occurred with Matplotlib 3.8.3 and 3.8.4 as well.

spyoungtech commented 3 months ago

Hmm. Would you be able to provide some minimal code that can be used to reproduce this problem?

As a stab in the dark, based on my experience with similar issues on MacOS, you may find that changing/upgrading the underlying version of tcl/tk fixes the issue. The version of tcl/tk being used may depend on how you installed Python (e.g., with brew or the official installer). If you used brew to install Python and tcl/tk for example, consider seeing if an upgrade is available or try the official installer with bundled tcl/tk instead (or vice versa).

eric-pfi commented 3 months ago

Very reasonable request, but unfortunately putting in way too much time for a deadline that I'm behind on, so building a reproducible case is a non-starter. I can answer part of the question, my python was installed from the official installer, and I was running 3.12.2 when I hit it the first time, and installed 3.12.5 to see if that helped, and it did not.