You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I see segfaults when using simple maplotlib/pylab features:
$ ipython --matplotlib
import pylab
import numpy as np
x = np.random.randn(16, 16)
pylab.imshow(x)
exit()
Segmentation fault
My matplotlibrc:
backend: WXAgg
This is on Linux w/ matplotlib 1.5.0, python 2.7.10 and wxPython 3.0.2.0. I got this failures using Enthought Canopy, but could reproduce it w/ anaconda and debian packages (debian being 1.5.0rc2). I could also see it on windows and mac, so I don't think it is a packaging issue.
Indeed. I can get you a traceback on Linux, but it would be nice to reproduce this without depending on MPL (I suspect this is a wxpython 3 issue more than matplotlib). Would be happy to work w/ someone from the team if that helps
If I remember correctly, it is a combination of a matplotlib/wxpython
issue. There is something about the way we clean things up that is causing
a freeing of uninitialized memory in wxpython. More specifically, by not
starting the event loop in wxpython, but having an instantiated wx
application, I think.
Indeed. I can get you a traceback on Linux, but it would be nice to
reproduce this without depending on MPL (I suspect this is a wxpython 3
issue more than matplotlib). Would be happy to work w/ someone from the
team if that helps
—
Reply to this email directly or view it on GitHub #5609 (comment)
.
FWIW: I can't reproduce on Fedora 23 with (all system packages) Python 2.7.10, wxPython 3.0.2 and matplotlib 1.5.0 installed from source. This is true both at the raw Python repl and in IPython 3.2.1. What version of IPython are you on? It installs an inputhook.
Sorry about that. I've updated the blog post. Not sure why you're getting that error message. Never seen it before.
Fedora 23 has built-in gdb Python debugging support (if you install python-debuginfo and use the system packages) -- in that event it doesn't require my "hack" to make it work for any Python. But that's the same OS I'm unable to reproduce the bug on, so the likelihood of it breaking so you can debug it there is slim.
In any event, the crash is happening in the Window destructor (Window.Destroy), but it's not clear which window. (You probably know that Window in wx.Window is the base class of most widgets, not an app window). You could try to see which call to Destroy in backend_wx.py is crashing through tracing or print statements.
In terms of trying to have a minimal example to pass this to the wx folks, my money is on the wx.Frame (main application window). matplotlib does override the destructor here: https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/backend_wx.py#L1326
Maybe try to make a wx app with a wx.Frame that does something like that and see if you can reproduce? Or, heck, try commenting out the Destroy method at L1326 and see if that resolves the issue.
@DietmarSchwertberger There have been various fixes to the wx backend since this was opened so it's likely that its fixed. I dont use this on a regular basis so I havn't tested it
Seems to work for me on Python 2.7.13, IPython 5.5.0, wxPython 3.0.2.0 (wx-3.0-gtk2), mpl 2.1.2, ArchLinux 2017.08
No crash with the plot window open or closed when entering exit().
Without the check for self.IsBeingDeleted from PR #5639 I can see the core dump when using exit() while the window is open.
@anntzer: do you have a pure Python+wx+Matplotlib script that causes the crash? I.e. without Ipython or similar? Is it with stock Python/mpl/wxpython installations or with a distribution like Anaconda?
For what it's worth, I've had various issues when using wxPython with pylab, though not this particular problem. It has been suggested to me to import directly from matplotlib and numpy, etc., and not use pylab at all. That has resolved all my problems.
However, I realized that I also have a warning (when importing wx) that's likely relevant :-)
In [1]: import wx
/usr/lib/python2.7/site-packages/wx-3.0-gtk3/wx/_core.py:16629: UserWarning: wxPython/wxWidgets release number mismatch
warnings.warn("wxPython/wxWidgets release number mismatch")
fwiw:
In [3]: wx._core.RELEASE_VERSION
Out[3]: 2
In [4]: wx._core_.RELEASE_VERSION
Out[4]: 3
Activity
jenshnielsen commentedon Dec 3, 2015
Sounds related to #3316
cournape commentedon Dec 3, 2015
Indeed. I can get you a traceback on Linux, but it would be nice to reproduce this without depending on MPL (I suspect this is a wxpython 3 issue more than matplotlib). Would be happy to work w/ someone from the team if that helps
WeatherGod commentedon Dec 3, 2015
If I remember correctly, it is a combination of a matplotlib/wxpython
issue. There is something about the way we clean things up that is causing
a freeing of uninitialized memory in wxpython. More specifically, by not
starting the event loop in wxpython, but having an instantiated wx
application, I think.
Again, this is all from memory.
On Thu, Dec 3, 2015 at 8:45 AM, David Cournapeau notifications@github.com
wrote:
mdboom commentedon Dec 3, 2015
FWIW: I can't reproduce on Fedora 23 with (all system packages) Python 2.7.10, wxPython 3.0.2 and matplotlib 1.5.0 installed from source. This is true both at the raw Python repl and in IPython 3.2.1. What version of IPython are you on? It installs an inputhook.
https://github.com/ipython/ipython/blob/40c34d3369c3d271149e13ac07f1bd2f5a716635/IPython/lib/inputhookwx.py
Can you get us a gdb backtrace? Even if not isolated from matplotlib, it might be helpful to see where the segfault is occurring.
cournape commentedon Dec 3, 2015
This is the gdb stacktrace I get:
With the following script (ran from python, not ipython):
mdboom commentedon Dec 3, 2015
Any chance you could get a Python backtrace from gdb as well? I usually set up gdb like this, then I can do
py-btto get a Python backtrace as well.cournape commentedon Dec 3, 2015
(I found a few typos in your gdbinit, and the link is now broken for
libpython.py)This is what it should look like I think:
cournape commentedon Dec 3, 2015
I am afraid I can't get
py-btto work, though. I get this error:cournape commentedon Dec 3, 2015
I am running debian unstable, which OS are you running gdb w/
py-btsupport on ? I can try to get that working on a VM ?mdboom commentedon Dec 3, 2015
Sorry about that. I've updated the blog post. Not sure why you're getting that error message. Never seen it before.
Fedora 23 has built-in gdb Python debugging support (if you install python-debuginfo and use the system packages) -- in that event it doesn't require my "hack" to make it work for any Python. But that's the same OS I'm unable to reproduce the bug on, so the likelihood of it breaking so you can debug it there is slim.
In any event, the crash is happening in the Window destructor (Window.Destroy), but it's not clear which window. (You probably know that
Windowinwx.Windowis the base class of most widgets, not an app window). You could try to see which call toDestroyinbackend_wx.pyis crashing through tracing or print statements.In terms of trying to have a minimal example to pass this to the wx folks, my money is on the
wx.Frame(main application window). matplotlib does override the destructor here: https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/backend_wx.py#L1326Maybe try to make a wx app with a wx.Frame that does something like that and see if you can reproduce? Or, heck, try commenting out the
Destroymethod at L1326 and see if that resolves the issue.RobinD42 commentedon Dec 8, 2015
See PR #5639
jenshnielsen commentedon Dec 9, 2015
closed by #5639 ping if you can still reproduce to have it reopened
10 remaining items
jenshnielsen commentedon Feb 8, 2018
@DietmarSchwertberger There have been various fixes to the wx backend since this was opened so it's likely that its fixed. I dont use this on a regular basis so I havn't tested it
anntzer commentedon Feb 8, 2018
I still have a segfault at exit on py2.7 mpl2.1.2 wxpython 3.0.2.0 arch linux.
DietmarSchwertberger commentedon Feb 8, 2018
Seems to work for me on Python 2.7.13, IPython 5.5.0, wxPython 3.0.2.0 (wx-3.0-gtk2), mpl 2.1.2, ArchLinux 2017.08
No crash with the plot window open or closed when entering
exit().Without the check for
self.IsBeingDeletedfrom PR #5639 I can see the core dump when usingexit()while the window is open.DietmarSchwertberger commentedon Feb 17, 2018
@anntzer: do you have a pure Python+wx+Matplotlib script that causes the crash? I.e. without Ipython or similar? Is it with stock Python/mpl/wxpython installations or with a distribution like Anaconda?
anntzer commentedon Feb 17, 2018
It's Arch Linux's distro python2+wxpython+matplotlib, just
DietmarSchwertberger commentedon Feb 17, 2018
@anntzer : still can't reproduce it...
zong commentedon Feb 18, 2018
For what it's worth, I've had various issues when using wxPython with pylab, though not this particular problem. It has been suggested to me to import directly from matplotlib and numpy, etc., and not use pylab at all. That has resolved all my problems.
anntzer commentedon Feb 18, 2018
also segfaults.
However, I realized that I also have a warning (when importing wx) that's likely relevant :-)
fwiw:
Perhaps a distro packaging issue?
DietmarSchwertberger commentedon Feb 18, 2018
I see the warning as well, but not the segfault.
anntzer commentedon Apr 24, 2018
Closing as only affecting wx3 (wx4 does not appear to suffer from the issue), which is not supported by mpl3.
Still left a target of 2.2.3, in case anyone wants to visit this...