-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Using Ctrl-W to close a matplotlib window opened by exec-ing a script in wxpython causes a segfault under linux #3690
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
Comments
Turns out it also happens without any script execution:
|
I can confirm this. I suspect that this is related to #3316. The Qt backends had a similar (but less fatal) issue where the root cause was that things were getting torn down in the wrong, the python and c/c++ layers are getting out of sync as to what still exists and something is trying to use an object that has already been deleted. Someone who knows the wx frame work needs to trace through how the keybinding call-backs to close the figure are different that the callbacks from the close window button. |
I have come across this bug in my refactor #4143 Almost fixed it, quite a nasty little thing to track down, but I should hopefully have it patched up soon. |
Patch in, I had already fixed it a while ago, but I had gone beyond to the next error that sometimes sits behind the segfault, which I have now tracked down to the canvas (and thus completely unrelated to the refactor, so I shall stop at this point). I tested the refactor on import matplotlib
matplotlib.use('Wx')
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(5)
y = 2*x
plt.figure()
plt.plot(x,y)
#plt.figure()
#plt.scatter(x,y)
plt.show()
print('Done') The segmentation bug meant that the application died before ever getting to python clearing up, so these assertion errors never showed up (it also meant that both windows got shut by a single http://mailman.paulmcnett.com/pipermail/floatcanvas/2014-February/001227.html makes it look like this assertion error comes from garbage collection of P.S. my refactor for wx lies in OceanWolf/matplotlib@backend-refactor...backend-refactor-wx |
Oh, and if you want to see the assert failiure bug on master (or released), just resize and close the window using the close button, as that doesn't trigger the Segfault. |
Probably related to #3316 |
This bug is still around, right? When I comment class FigureCanvasWx(FigureCanvasBase, wx.Panel):
def _onKeyDown(self, evt):
key = self._get_key(evt)
FigureCanvasBase.key_press_event(self, key, guiEvent=evt)
if self:
evt.Skip()
def _onKeyUp(self, evt):
key = self._get_key(evt)
FigureCanvasBase.key_release_event(self, key, guiEvent=evt)
if self:
evt.Skip() If the underlying C++ object is destroyed, the boolean value of Of course it would be better not to call I also tried calling the frame's @MichaelClerx: could you please try this? If it is effective for you and not better solution shows up, then I will submit a pull request. |
Thanks @DietmarSchwertberger It's been a while, so I checked and the original example still produces a segfault on Fedora 26, Python 2.7.14, Matplotlib 2.0.0, wx 3.0.2.0 gtk3 (classic). I then made the changes to |
How to reproduce:
Run the application, hit the run button and close the generated graph using Ctrl-W (closing the window in other ways does not crash the application).
It works fine on windows 7 (matplotlib 1.3.1 and wxpython 2.8.12.1 (msw-unicode)) but crashes under linux (matplotlib 1.3.1 and wxpython wx.2.8.12.0 (gtk2-unicode), Fedora 20, Gnome 3.10.2).
Not sure if this is a wx, wxpython or matplotlib bug.
See also:
Debug output from gdb:
The text was updated successfully, but these errors were encountered: