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
To reproduce, run the script with python example.py. This produces the following segfault:
[1] 62624 segmentation fault python example.py
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 the macosx backend.
Operating system: macOS 10.15.4
Matplotlib version: 3.2.1
Matplotlib backend: macosx
Python version: 3.8.2
I can reproduce this problem with Homebrew Python as well as Anaconda.
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 ?
NSAutoreleasePool* pool = [[NSAutoreleasePoolalloc] init];
[window close];
[pool release];
self->window = NULL;
}
Py_RETURN_NONE;
}
If I comment out the lines related to the pool in FigureManager_destroy (i.e. lines 756 and 758), the example works. However, I'm not sure if this doesn't leave deleted windows lying around because I'm absolutely not familiar with this codebase.
Activity
QuLogic commentedon Apr 7, 2020
Can you get a backtrace?
tacaswell commentedon Apr 7, 2020
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 ?
jklymak commentedon Apr 7, 2020
On master:
cbrnr commentedon Apr 8, 2020
@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).
anntzer commentedon Apr 8, 2020
Can't test this, but first thing I'd consider is adding a check whether
canvasis NULL at https://github.com/matplotlib/matplotlib/blob/master/src/_macosx.m#L1730 -- possibly https://github.com/matplotlib/matplotlib/blob/master/src/_macosx.m#L349 has already been called at that point.cbrnr commentedon Apr 8, 2020
I changed this function to:
I still get the segfault though (after I made the changes I did
pip install -ve .so that should have worked).anntzer commentedon Apr 8, 2020
Well, guessed wrong, then :)
cbrnr commentedon Apr 9, 2020
Not sure why there are these two very similar functions:
matplotlib/src/_macosx.m
Lines 723 to 734 in a86d4fb
matplotlib/src/_macosx.m
Lines 750 to 762 in a86d4fb
If I comment out the lines related to the
poolinFigureManager_destroy(i.e. lines 756 and 758), the example works. However, I'm not sure if this doesn't leave deleted windows lying around because I'm absolutely not familiar with this codebase.tacaswell commentedon Apr 9, 2020
@cbrnr can you put in a (draft) PR with your changes?
cbrnr commentedon Apr 9, 2020
Yes, will do.
cbrnr commentedon Apr 9, 2020
@tacaswell see #17084.