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
wx crashes on exit if figure not shown and not explicitly closed #3316
Comments
Can you provide the full output from the crash? |
Does anybody remember if 1.3.1 has the updated wx Backend or not?
|
All I get is a "python has stopped working" popup, no other output. On Sun, Jul 27, 2014 at 7:31 PM, Benjamin Root notifications@github.com
|
@Tillsten can you reproduce this? |
@ibell Could you re-try this with one of the RCs for 1.4.0? |
Running the OP's command does not produce an error on my machine (win 7 x64). However, at the advice of @tacaswell , running If I click Debug the program, VS2008 pops up and shows that python terminated due to an Digging a little deeper results in a list of disassembly code with an arrow pointing to this line: As this was not terribly helpful (at least for me), running the same code in debug mode of PyCharm Community results in this error:
Hope this helps, mpl devs! |
binaries? Building on windows isn't exactly a lot of fun... On Sun, Aug 17, 2014 at 11:48 PM, Thomas A Caswell <notifications@github.com
|
And the code runs fine on linux. |
Nope, same problem (same versions) when I try to run python -c "import matplotlib; matplotlib.use('wxagg'); import On Mon, Aug 18, 2014 at 12:35 AM, Thomas A Caswell <notifications@github.com
|
The |
Yeah I reset my default backend to TkAgg due to the crashing with WXAgg :( On Mon, Aug 18, 2014 at 12:44 AM, Thomas A Caswell <notifications@github.com
|
If you are going to run the code with out showing the figure, I would use the Does Does |
Yes, the plt.close('all') does "fix" it. As does the plt.show() In general it's nicer to just be able to always use WXAgg since I do a On Mon, Aug 18, 2014 at 1:04 AM, Thomas A Caswell notifications@github.com
|
If this is a problem only upon shutdown, then perhaps an "atexit" function could be registered to clean up; I don't know whether it would be called early enough to prevent the crash. It could be registered when pyplot is imported, and simply do "plt.close('all')". |
To clarify: this would be part of pyplot, so user code would not need to bother with it. |
I can reproduce this with wx 3.0.0.0 but not with wx 2.8.12.1. Faulthandler gives the following output (using matplotlib 1.4.0rc4):
The crash is in the
|
Reproduced the bug with the following setup. OS: GNU/Linux amd64
|
WxAgg just underwent a major overhaul in the master branch. Could someone On Tue, Jun 30, 2015 at 12:42 AM, heroxbd notifications@github.com wrote:
|
I can reproduce the seg fault on current master on OSX wx and wxpython 3.0.2 from brew |
For what is worth it doesn't seqfault using python 3 and wx phoenix but raises a runtime error
|
Looks to me like it is trying to destroy a frame which was never created because show was never called. |
@WeatherGod
|
Interestingly this lead me to find: #4572 For reference (even if it looks a bit useless to me):
If you try to call 22:21 $ git diff
diff --git a/lib/matplotlib/_pylab_helpers.py b/lib/matplotlib/_pylab_helpers.py
index c5ea8cc..cf6011c 100644
--- a/lib/matplotlib/_pylab_helpers.py
+++ b/lib/matplotlib/_pylab_helpers.py
@@ -149,4 +149,4 @@ class Gcf(object):
if force or f_mgr.canvas.figure.stale:
f_mgr.canvas.draw_idle()
-atexit.register(Gcf.destroy_all)
+# atexit.register(Gcf.destroy_all) prevents the segfault. I would be interested if this could be reproduced using only WX classes. I have re-milestoned this as 'proposed next point release' as I do not think that this should be a blocker for the next release (but am open to arguments otherwise). |
From reading the above it looks like this bug affects more than Basically if I know what to test, I can see if MEP27 fixes it as a lot of code involved in window generation/destruction has been refactored, if this happened due to a race condition (or even another problem), then it stands a good chance that I have already fixed it... |
@OceanWolf, thanks for your input. Unfortunately backend-refactor-wx at https://github.com/OceanWolf/matplotlib.git does not fix the bug. $ python -c "import matplotlib; matplotlib.use('wxagg'); import matplotlib.pyplot as plt; plt.plot([0,1],[1,4]);" |
I am thinking that a quick-n-dirty solution to this problem would be for us Just curious, does the segfault happen if you do a fig.savefig()? On Thu, Jul 9, 2015 at 5:55 AM, heroxbd notifications@github.com wrote:
|
I think I see the problem, we create a window, but never actually show it, so we never have anything GUI to close. @heroxbd Thanks for the code. I can see why MEP27 doesn't fix it, though I think it will make it easier to fix (note also that When I resume the MEP27 work on the other backends I will take a look at fixing this (though I might need a reminder). |
Benjamin Root notifications@github.com writes:
Yes, it segfaults no matter if you called savefig() or not. |
Hi all, I finally got a chance to dig into this issue with the debugger. The guesses so far have been on the right track about a conflict with wx's cleanup and PR #5639 will fix this and should be safe for all versions of wx. |
Hi All, |
Same as @bikramditya, can repro on OSX Yosemite with matplotlib 1.5.1 and wxPython 3.0.2.0 with the following three-line program, which hangs on the last line: import wx
import pylab
app = wx.App(False) Does not occur if wx alone is imported. Does not occur with either matplotlib 1.4.3 or wxPython 2.8.12.1. |
@ZonG0 I think you are seeing a different problem. If you are creating your own |
I gave that only as a minimal example. There is something obviously wrong when two imports cannot coexist. Edit: Was able to get past the last line hanging by prepending import matplotlib
matplotlib.use("wxAgg") |
On windows, with the wxagg backend, if the figure is not explicitly closed, python crashes. This crashes:
versions:
The text was updated successfully, but these errors were encountered: