-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Segmentation fault with macosx backend #17061
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
Can you get a backtrace? |
See https://docs.python.org/3/library/faulthandler.html for how to get a good backtrace. My guess is that we are not being careful enough not reusing dead objects in the OSX backend. My guess is that the double close is trying to tear down a already torn down objectivec object which leads to a null deference which leads to segfault? I wonder if #16942 has already fixed this, can you try installing from master @cbrnr ? |
On master:
|
@jklymak beat me to it, the traceback points to the same line for me (https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/_pylab_helpers.py#L86). |
Can't test this, but first thing I'd consider is adding a check whether |
I changed this function to: - (void)windowWillClose:(NSNotification*)notification
{
PyGILState_STATE gstate;
PyObject* result;
gstate = PyGILState_Ensure();
if(canvas != NULL)
{
result = PyObject_CallMethod(canvas, "close_event", "");
if(result)
Py_DECREF(result);
else
PyErr_Print();
}
PyGILState_Release(gstate);
} I still get the segfault though (after I made the changes I did |
Well, guessed wrong, then :) |
Not sure why there are these two very similar functions: Lines 723 to 734 in a86d4fb
Lines 750 to 762 in a86d4fb
If I comment out the lines related to the |
@cbrnr can you put in a (draft) PR with your changes? |
Yes, will do. |
@tacaswell see #17084. |
The following short example produces a segmentation fault when using the default
macosx
backend (of course on macOS):To reproduce, run the script with
python example.py
. This produces the following segfault:Running the code in interactive mode works. Also,
block=True
does not produce the segfault.This script also runs normally with the
PyQt5
backend, e.g.MPLBACKEND=qt5agg python example.py
, so it seems like this is an issue with themacosx
backend.I can reproduce this problem with Homebrew Python as well as Anaconda.
The text was updated successfully, but these errors were encountered: