Skip to content

[Bug]: Segmentation fault when resizing on Python 3.12 and MacOS 14 #27262

Closed

Description

@JRI98

Bug summary

I upgraded Python from 3.11 to 3.12 and now I am unable to resize the window, even with a simple plot.
Apart from that, the plots are displayed correctly and I can move the window.

Code for reproduction

import matplotlib.pyplot as plt

plt.subplots()
plt.show()

Actual outcome

[1] xxxxx segmentation fault python3.12 main.py

Expected outcome

I expected the window to be resized without crashing

Additional information

No response

Operating system

MacOS 14

Matplotlib Version

3.8.1

Matplotlib Backend

MacOSX

Python version

3.12.0

Jupyter version

No response

Installation

pip

Activity

  1. dopplershift commented on Nov 3, 2023

    @dopplershift
    Contributor

    Confirming that I was able to reproduce with Python 3.12 and Matplotlib 3.8.1 from conda-forge, macOS 14.1 on an M2.

    EDIT: This is using the macosx backend

  2. greglucas commented on Nov 3, 2023

    @greglucas
    Contributor

    I cannot reproduce on an Intel Mac with matplotlib 3.8.1 from PyPI, so possibly just ARM related? Does 3.8.0 work as expected?

  3. JRI98 commented on Nov 3, 2023

    @JRI98
    Author

    I cannot reproduce on an Intel Mac with matplotlib 3.8.1 from PyPI, so possibly just ARM related? Does 3.8.0 work as expected?

    Yeah I forgot to mention this happens on an M1.
    I also tried version 3.8.0 and 3.7.0, but get the same result. The bug appears to be related to the use of Python 3.12

  4. ksunden commented on Nov 3, 2023

    @ksunden
    Member

    I can also reproduce (previously had py3.11 on that machine, so did not run into it)

    Here is the faulthandler:

    kyle@aluminum matplotlib % python -X faulthandler 
    Python 3.12.0 (main, Nov  3 2023, 10:35:24) [Clang 15.0.0 (clang-1500.0.40.1)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import matplotlib.pyplot as plt
    >>> plt.plot([2,5,1])
    [<matplotlib.lines.Line2D object at 0x12286e1b0>]
    >>> plt.show()
    Fatal Python error: Segmentation fault
    
    Current thread 0x00000001e52b5300 (most recent call first):
      File "/Users/kyle/.pyenv/versions/edge-312/lib/python3.12/site-packages/matplotlib/backends/backend_macosx.py", line 183 in start_main_loop
      File "/Users/kyle/.pyenv/versions/edge-312/lib/python3.12/site-packages/matplotlib/backend_bases.py", line 3448 in show
      File "/Users/kyle/.pyenv/versions/edge-312/lib/python3.12/site-packages/matplotlib/pyplot.py", line 527 in show
      File "<stdin>", line 1 in <module>
    
    Extension modules: numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, matplotlib._c_internal_utils, PIL._imaging, matplotlib._path, kiwisolver._cext, matplotlib._image, matplotlib.backends._macosx (total: 19)

    Can also confirm that it seems specific to the macosx backend (e.g. qt does not segfault)

    No surprise, but the innermost python call identified by the faulthandler traceback is a line calling into the obj-C extension module:

    Edit: Python compiled from source via pyenv, so not specific to conda.

  5. tacaswell commented on Nov 6, 2023

    @tacaswell
    Member

    This suggests that the issues is with our extension module and have been bit by the c-level changes in upstream.

  6. ksunden commented on Nov 8, 2023

    @ksunden
    Member

    Bisects to python/cpython@df3173d (python/cpython#101660)

    That commit changed memory allocation behavior, though not immediately obvious to me what we are doing wrong (if anything).

    The stated intent of the change is to enable per-subinterpretter GIL, though we do not (intentionally) use that feature (though the commit message does indicate value outside of that, and also states that the errors are indicative of problems down the line).

  7. added this to the v3.8.2 milestone on Nov 8, 2023
  8. modified the milestones: v3.8.2, v3.7.4 on Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions