Description
Bug summary
On current main, clicking on the subplot tool the additional figure pops up and can be interacted with properly, however when clicking the close button the app crashes with a segfault. Possibly trying to release an object that has already been released/garbage collected previously... I can only reproduce this by clicking the subplot button. Manually calling fig.canvas.toolbar.configure_subplots()
seems to work fine when closing that window. Perhaps we need an explicit retain on the objc side...
This was brought about by the change to ARC in #23060. I'm going to put the release critical label on it, because a segfault seems worse than memory leaks. Probably smart to revert #23060 if no one has an immediate fix for it.
Code for reproduction
import matplotlib.pyplot as plt
plt.figure()
plt.show()
Actual outcome
Relevant traceback:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000020
Exception Codes: 0x0000000000000001, 0x0000000000000020
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process: exc handler [42279]
VM Region Info: 0x20 is not in any region. Bytes before following region: 140737486852064
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
VM_ALLOCATE 7fffffe91000-7fffffe92000 [ 4K] r-x/r-x SM=ALI
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libobjc.A.dylib 0x7ff80c2cd01f objc_release + 31
1 libobjc.A.dylib 0x7ff80c2d10da AutoreleasePoolPage::releaseUntil(objc_object**) + 164
2 libobjc.A.dylib 0x7ff80c2cdf5f objc_autoreleasePoolPop + 168
3 CoreFoundation 0x7ff80c4bfb8a _CFAutoreleasePoolPop + 22
4 Foundation 0x7ff80d3334f0 -[NSAutoreleasePool drain] + 133
5 AppKit 0x7ff80ef2bf9b -[NSApplication run] + 636
6 _macosx.cpython-310-darwin.so 0x1161d13c3 show + 211
Expected outcome
No segfault
Additional information
No response
Operating system
No response
Matplotlib Version
main
Matplotlib Backend
macosx
Python version
No response
Jupyter version
No response
Installation
No response