Phoenix icon indicating copy to clipboard operation
Phoenix copied to clipboard

wxOverlay on mac causes crash on shutdown if not deleted before shutting down.

Open ChrisBarker-NOAA opened this issue 2 years ago • 0 comments

wxMac -- a couple versions, but currently: 11.7.9

wxPython version & source: 4.2.1 from conda-forge (but antoher user has reported on 4.2.0 and from PyPi, I think)

Python version & source: Python 3.9 and 3.10 -- conda-forge (but others have reported it on other builds)

Description of the problem:->

If there is a wx.Overlay still around when the app shuts down, you get a segfault on closing it.

 line 3: 10056 Segmentation fault: 11  /Users/chris.barker/miniconda3/envs/floatcanvas/python.app/Contents/MacOS/python "$@"

The solution is to delete the wx.DCOverlay before clearing the wx.Overlay. Here's the code that works, in lib.floatcanvas.GUI RubberBandBox (in #2448):

  odc = wx.DCOverlay(self.overlay, dc)
  del odc  # needs to be deleted before clearing the overlay, or it will crash on exit
  self.overlay.Reset()

without that del -- it crashes on exit, and trying to delete the wx.Overlay instead is ugly -- I had to do it in a wx.CallAfter (probably because the wx.DCOverlay was still around)

Not too bad to work around once I figure it out, but ideally it should not be possible to get a segfault with Python code.

ChrisBarker-NOAA avatar Aug 23 '23 00:08 ChrisBarker-NOAA