WxPython segmentation fault on Python 3.12 with 4.2.1 on macOS
facelessuser opened this issue · 4 comments
Operating system: macOS Ventura 13.5.1
wxPython version & source: 4.2.1 osx-cocoa (phoenix) wxWidgets 3.2.2.1
Python version & source: 3.12rc2
Description of the problem:
I know that 3.12 is not fully supported yet, but is in beta (based on the changelog), but with the last RC just released for Python 3.12, it is probably good to make issues known sooner rather than later. I do not know if this issue is a wxPython issue or some issue in Python 3.12. This issue may or may not already be known, but I couldn't find a current issue open on this.
The issue is that if you create a wxPython app on macOS with 3.12, after closing the app, during exit from Python, you get a segfault. This only happens after you've run and closed a wxPython app. The only way I've found to sidestep the segfault is to call os._exit()
which skips cleanup. It seems wxPython leaves something in a bad state so that during the cleanup step of a traditional exit, a segfault occurs.
As mentioned, this only occurs on 3.12 with wxPython 4.2.1. On Python 3.11 with 4.2.1 there is no segfault.
This can be reproduced with the most basic example:
import wx
def main():
app = wx.App(redirect=True)
top = wx.Frame(None, title="Hello World", size=(300,200))
top.Show()
app.MainLoop()
if __name__ == "__main__":
main()
Output:
$ python3.12 demo.py
[1] 26087 segmentation fault python3.12 demo.py
As a matter of fact, I can reproduce this just by importing wxPython and then exiting.
Python 3.12.0rc2 (v3.12.0rc2:40913a56ed, Sep 5 2023, 20:28:55) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> exit()
[1] 26380 segmentation fault python3.12
This does not occur with any other code I've tested in Python 3.12 during its RC releases:
Python 3.12.0rc2 (v3.12.0rc2:40913a56ed, Sep 5 2023, 20:28:55) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print('hello world')
hello world
>>> exit()
I think this might have been due to changes needed in sip. Can you try the latest snapshot build to see if the problem still exists?
There was no segfault with:
wxPython-4.2.2a1.dev5626+a1184286-cp312-cp312-macosx_10_10_universal2.whl | 2023-08-31 02:22
So this looks like it may be fixed in the next release.