Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.12.4 seg faulting when running pytest with mpl #120387

Closed
bje- opened this issue Jun 12, 2024 · 5 comments
Closed

Python 3.12.4 seg faulting when running pytest with mpl #120387

bje- opened this issue Jun 12, 2024 · 5 comments
Labels
3.12 bugs and security fixes type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@bje-
Copy link

bje- commented Jun 12, 2024

Crash report

What happened?

This test file causes Python to seg fault when run with python3.12 -m pytest test_example.py:

import pytest
import unittest
import matplotlib.pyplot as plt

class TestUtils(unittest.TestCase):

    @pytest.mark.mpl_image_compare
    def test_figure_1(self):
        return plt.figure()

I have run it under GDB and got the following backtrace:

Thread 1 "python3.12" received signal SIGSEGV, Segmentation fault.
0x00000000005333f0 in _PyInterpreterState_GET () at ../Include/internal/pycore_pystate.h:133
(gdb) bt
#0  0x00000000005333f0 in _PyInterpreterState_GET () at ../Include/internal/pycore_pystate.h:133
#1  get_state () at ../Objects/obmalloc.c:866
#2  _PyObject_Free (p=0x20bf0b0, ctx=0x0) at ../Objects/obmalloc.c:1850
#3  PyMem_Free (ptr=0x20bf0b0) at ../Objects/obmalloc.c:732
#4  0x00007fffe5921839 in sip_api_free (mem=<optimised out>) at ../../../../sip/siplib/siplib.c:2162
#5  0x00007fffe591d61d in sipOMFinalise (om=om@entry=0x7fffe593fec0 <cppPyMap>)
    at ../../../../sip/siplib/objmap.c:69
#6  0x00007fffe5921a2f in finalise () at ../../../../sip/siplib/siplib.c:2064
#7  0x00000000004630c1 in call_ll_exitfuncs (runtime=<optimised out>) at ../Python/pylifecycle.c:3046
#8  Py_FinalizeEx () at ../Python/pylifecycle.c:2005
#9  0x0000000000657a9e in Py_RunMain () at ../Modules/main.c:711
#10 0x0000000000610acd in Py_BytesMain (argc=<optimised out>, argv=<optimised out>) at ../Modules/main.c:763
#11 0x00007ffff7c29d90 in __libc_start_call_main
     (main=main@entry=0x610a10 <main>, argc=argc@entry=4, argv=argv@entry=0x7fffffffe2b8)
    at ../sysdeps/nptl/libc_start_call_main.h:58
#12 0x00007ffff7c29e40 in __libc_start_main_impl
     (main=0x610a10 <main>, argc=4, argv=0x7fffffffe2b8, init=<optimised out>, fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7fffffffe2a8) at ../csu/libc-start.c:392
#13 0x0000000000610945 in _start ()

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

Python 3.12.4 (main, Jun 12 2024, 16:49:51) [GCC 11.4.0]

@bje- bje- added the type-crash A hard crash of the interpreter, possibly with a core dump label Jun 12, 2024
@sobolevn sobolevn added the 3.12 bugs and security fixes label Jun 12, 2024
@mdboom
Copy link
Contributor

mdboom commented Jun 12, 2024

I can't reproduce this myself, fwiw (on Debian Linux). Seeing sip_api_free in the traceback makes me think this is related to PyQt. Does using a different matplotlib backend resolve the issue? Is it possible to create the crash on a simple PyQt example application alone (without matplotlib and pytest in the mix?)

@bje-
Copy link
Author

bje- commented Jun 12, 2024

Thanks for your help. I've managed to remove pytest from the picture with just this:

>>> import matplotlib.pyplot as plt
>>> plt.figure()
<Figure size 640x480 with 0 Axes>
>>> 
Segmentation fault (core dumped)

I'll try a different Matplotlib backend as you suggest.

@bje-
Copy link
Author

bje- commented Jun 12, 2024

I switched to the PDF backend and the segfault goes away. The default backend is:

>>> import matplotlib
>>> matplotlib.get_backend()
'WxAgg'

@bje-
Copy link
Author

bje- commented Jun 12, 2024

This tiny wxPython test case crashes once the main window is closed. I am using wxPython 4.1.2 installed via pip.

import wx
app = wx.App()
frm = wx.Frame(None, title="Hello World")
frm.Show()
app.MainLoop()

@bje-
Copy link
Author

bje- commented Jun 12, 2024

Here's the bug: wxWidgets/Phoenix#2455

Not a Python core bug, quite obviously, so closing.

@bje- bje- closed this as completed Jun 12, 2024
@Eclips4 Eclips4 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

4 participants