Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Segmentation fault when blitting onto closed figure (TkAgg) #16580

Copy link
Copy link
Closed
@dranjan

Description

@dranjan
Issue body actions

Bug report

Bug summary

With the "TkAgg" backend, calling figure.canvas.blit on a closed Figure instance crashes the Python interpreter with "segmentation fault." An easy workaround is to check if the figure is closed using plt.fignum_exists(figure.number) before attempting the blit operation.

I tried a couple other backends and they didn't crash.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

fig, axes = plt.subplots()
axes.imshow(np.zeros((1000, 1000, 3), dtype=np.uint8))
fig.canvas.draw()
plt.close(fig.number)
fig.canvas.blit(axes.bbox)

Actual outcome

zsh: segmentation fault (core dumped)  python segfault2.py

Expected outcome

I'm not really sure, but segfaulting the interpreter isn't it. I think an acceptable alternative would be raising a Python exception from within matplotlib.

Matplotlib version

  • Operating system: Ubuntu 18.04.4
  • Matplotlib version: 3.1.3
  • Matplotlib backend: TkAgg
  • Python version: 3.6.9

matplotlib was installed from pip in a virtualenv.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.