matplotlib / matplotlib/matplotlib
[Bug]: macOS: qtagg backend crashes on Control-C after input()
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 23.2k
- Forks
- 8.5k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 66
Description
### Bug summary
1. Run the attached code in qtagg on macosx
2. Press Control-C to send a SIGINT.
3. Click on the matplotlib Dock icon.
### Code for reproduction
```Python
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import cm
# matplotlib.use(backend="TkAgg")
plt.style.use("_mpl-gallery")
# Make data
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)
# Plot the surface
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
ax.plot_surface(X, Y, Z, vmin=Z.min() * 2, cmap=cm.Blues)
ax.set(xticklabels=[], yticklabels=[], zticklabels=[])
plt.show(block=False)
input("Hit [return] to end")
plt.close("all")
```
### Actual outcome
Crash.
[qtagg_crash.txt](https://github.com/user-attachments/files/29781774/qtagg_crash.txt)
### Expected outcome
I'm not 100% what the correct behavior should be, but not a crash. I was thinking that the Control-C would either stop the input() call or immediately close the figure.
### Additional information
_No response_
### Operating system
macOS 14.8
### Matplotlib Version
3.12.0.dev484+g162d8181d.d20260708
### Matplotlib Backend
qtagg
### Python version
3.14.5
### Jupyter version
_No response_
### Installation
None
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided Python reproduction with the qtagg backend on macOS, then inspect the qtagg backend involved in handling Control-C during input(). Use qtagg_crash.txt and the reported steps to determine the relevant failure path; done means the reproduction no longer crashes and the resulting interrupt or figure behavior is consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-graphics, desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100