Update: this issue is on a Mac M3 running Sonoma. Running on a Ubuntu 22.04 
machine, I do not get this bug. Personally I’m unblocked but this info is maybe 
useful still to you guys.

From: Alex Lewis <alex.le...@chaosinc.com>
Date: Wednesday, February 5, 2025 at 4:48 PM
To: dev@arrow.apache.org <dev@arrow.apache.org>
Subject: Bug: Matplotlib savefig() Crashes flight server
Hello Arrow Team!

I was looking for some support related to matplotlib being used in an Arrow 
flight server. Was having trouble requesting access to the flight Jira so I’m 
tossing in some info here.


Specifically, a call to plt.savefig() causes a Fatal Bus Error. The call to 
plt.savefig() can be called in either the do_action() or do_get() functions to 
cause the Bus Error. Example code inside of a server class that inherits from a 
pyarrow.flight.FlightServerBase:
    def do_get(self, context: pyarrow.flight.ServerCallContext, dataset_ticket: 
pyarrow.flight.Ticket):

            plt.figure()

            plt.plot([1, 2, 3, 4], [1, 4, 9, 16])

            buffer = BytesIO()

            print("created an image")

            plt.savefig(buffer, format='png')

A flight client call to do_get() will cause an error such as the one I’m tacked 
onto the end of this email.

Environment:

pyarrow = "^18.1.0"

matplotlib = "^3.10.0"

numpy = "1.26.4"

python = "3.11.3"





Let me know if I can provide any additional info!

-Alex Lewis





Here is an example of a traceback to a savefig call in a flight server method:
Fatal Python error: Bus error



Current thread 0x000000016c213000 (most recent call first):

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/numpy/linalg/linalg.py",
 line 561 in inv

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/transforms.py",
 line 1876 in inverted

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/transforms.py",
 line 1462 in __sub__

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/axis.py",
 line 2823 in get_tick_space

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/ticker.py",
 line 2166 in _raw_ticks

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/ticker.py",
 line 2236 in tick_values

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/ticker.py",
 line 2228 in __call__

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/axis.py",
 line 1536 in get_majorticklocs

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/axis.py",
 line 1292 in _update_ticks

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/axis.py",
 line 1362 in get_tightbbox

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/axes/_base.py",
 line 3089 in _update_title_position

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/axes/_base.py",
 line 3145 in draw

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/artist.py",
 line 71 in draw_wrapper

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/image.py",
 line 134 in _draw_list_compositing_images

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/figure.py",
 line 3257 in draw

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/artist.py",
 line 71 in draw_wrapper

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/artist.py",
 line 94 in draw_wrapper

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py",
 line 382 in draw

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py",
 line 429 in _print_pil

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py",
 line 481 in print_png

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/backend_bases.py",
 line 2040 in <lambda>

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/backend_bases.py",
 line 2184 in print_figure

  File 
"/Users/alex/chaos/chaotic/virtualenv/lib/python3.11/site-packages/matplotlib/figure.py",
 line 3490 in savefig

Reply via email to