Closed
Description
Bug report
Bug summary
If I try to save a figure with 1024**3 pixels or more, the Python interpreter crashes.
Code for reproduction
The following script segfaults for me on two separate machines:
#! /usr/bin/env python
import matplotlib
import sys
matplotlib.use('agg')
import matplotlib.pyplot as plt
if len(sys.argv) == 3:
figsize = (int(sys.argv[1]), int(sys.argv[2]))
else:
print('using default figsize')
figsize = (463, 232)
fig, ax = plt.subplots(figsize=figsize, dpi=100)
fig.savefig('big.png')
Actual outcome
This segfaults when trying to create this image. The image size is 46300 × 23200 = 1,074,160,000. For comparison, 1024**3 is 1,073,741,824.
Expected outcome
No segfault. If I run the script with arguments 462 232
to create an image of 1,071,840,000 pixels, I get no crash.
Matplotlib version
- Operating system: Centos 7.8 or Fedora 33
- Matplotlib version: 3.3.3
- Matplotlib backend (
print(matplotlib.get_backend())
): agg - Python version: 3.8.6
Matplotlib installed through Conda using conda-forge.
Other information
The relevant stacktrace is short:
#0 0x00007fffd699ffbd in agg::renderer_base<agg::pixfmt_alpha_blend_rgba<fixed_blender_rgba_plain<agg::rgba8T<agg::linear>, agg::order_rgba>, agg::row_accessor<unsigned char> > >::clear(agg::rgba8T<agg::linear> const&) [clone .part.61] [clone .lto_priv.101] ()
from /a/lib/python3.8/site-packages/matplotlib/backends/_backend_agg.cpython-38-x86_64-linux-gnu.so
#1 0x00007fffd6994d8d in PyRendererAgg_init(PyRendererAgg*, _object*, _object*) [clone .lto_priv.107] ()
from /a/lib/python3.8/site-packages/matplotlib/backends/_backend_agg.cpython-38-x86_64-linux-gnu.so
#2 0x0000555555683888 in type_call (kwds=0x0, args=0x7fffe773fe40, type=<optimized out>)
at /home/conda/feedstock_root/build_artifacts/python-split_1602094424782/work/Objects/typeobject.c:994
I am running this test on 64-bit machines and I can confirm that these are not simple out-of-memory errors.