Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WxPython segmentation fault on Python 3.12 with 4.2.1 on macOS #2455

Closed
facelessuser opened this issue Sep 6, 2023 · 18 comments
Closed

WxPython segmentation fault on Python 3.12 with 4.2.1 on macOS #2455

facelessuser opened this issue Sep 6, 2023 · 18 comments

Comments

@facelessuser
Copy link
Contributor

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()
@swt2c
Copy link
Collaborator

swt2c commented Sep 6, 2023

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?

https://wxpython.org/Phoenix/snapshot-builds/

@facelessuser
Copy link
Contributor Author

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.

@swt2c
Copy link
Collaborator

swt2c commented Sep 6, 2023

Great, it was most likely fixed by: d17fff1

@jpxd
Copy link

jpxd commented Dec 5, 2023

@swt2c Thanks for the fix! Is there any timeline for when to expect the next release of the module to PyPI with a new version which contains the fix? As of now running on Python 3.12 with the most current version on PyPI still produces crashes on exit.

@chigkim
Copy link

chigkim commented Mar 1, 2024

@swt2c Thanks for the fix! Is there any timeline for when to expect the next release of the module to PyPI with a new version which contains the fix? As of now running on Python 3.12 with the most current version on PyPI still produces crashes on exit.

I'm also having the same problem, would love to see the fix on pip. Thanks!

@swt2c
Copy link
Collaborator

swt2c commented Mar 1, 2024

Unfortunately, this project has a bus factor of 1 and only @RobinD42 can produce releases. :(

@WickyHuang
Copy link

When can I fix this bug in Windows? @RobinD42

@chigkim
Copy link

chigkim commented Apr 24, 2024

Any update, @RobinD42?

@sveinse
Copy link

sveinse commented May 23, 2024

As #2547 was closed as duplicated of this: This issue is applicable to Windows as well, not just macOS. Please upddate the issue title.

And why is this issue closed? The issue is not yet fixed, is it?

@swt2c
Copy link
Collaborator

swt2c commented May 24, 2024

And why is this issue closed? The issue is not yet fixed, is it?

It's fixed in git.

@sveinse
Copy link

sveinse commented May 24, 2024

OK. Is there a separate issue tracking the deployment of the fix?

@swt2c
Copy link
Collaborator

swt2c commented May 24, 2024

OK. Is there a separate issue tracking the deployment of the fix?

No, but I created one: #2553

@bje-
Copy link

bje- commented Jun 12, 2024

As #2547 was closed as duplicated of this: This issue is applicable to Windows as well, not just macOS. Please upddate the issue title.

This issue affects Linux as well.

@muye0503
Copy link

@swt2c

On Yocto, with Python 3.12.3 + wxPython 4.2.1. The issuse can be reproduced.
By patching the requirements/devel.txt, upgrade sip 6.7.9 => 6.7.11, the issue still exists.

@swt2c
Copy link
Collaborator

swt2c commented Jun 13, 2024

@swt2c

On Yocto, with Python 3.12.3 + wxPython 4.2.1. The issuse can be reproduced. By patching the requirements/devel.txt, upgrade sip 6.7.9 => 6.7.11, the issue still exists.

@muye0503 did you rebuild wxPython with the updated sip (ie, you probably need to remove and regenerate all the sip-generated files)?

@bje-
Copy link

bje- commented Jun 13, 2024

Is there any version in PyPI that I can use in requirements.txt to workaround this in the meantime?

@muye0503
Copy link

@swt2c
In my env, build wxPython-4.2.1 from tar ball with setup.py.
So the sip version is still 6.7.9.
Do you have any suggestion to build from tar ball with setup.py using upgraded sip?

Thanks

@bje-
Copy link

bje- commented Jun 21, 2024

As #2547 was closed as duplicated of this: This issue is applicable to Windows as well, not just macOS. Please update the issue title.

and Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants