Repository navigation
Closed
Description
Bug summary
Hello,
we got a couple of bug reports in Debian about matplotlib segfaulting on mipsel when running tests
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1000774
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1000435 (this is actually for astropy, but it fails the same as the one before)
Code for reproduction
running the test suiteActual outcome
build/lib.linux-mips64-3.10/matplotlib/tests/test_agg.py::test_repeated_save_with_alpha PASSED [ 0%]
build/lib.linux-mips64-3.10/matplotlib/tests/test_agg.py::test_large_single_path_collection Fatal Python error: Segmentation fault
Current thread 0x000000fff1dc1710 (most recent call first):
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/lines.py", line 840 in draw
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/artist.py", line 50 in draw_wrapper
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/axis.py", line 299 in draw
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/artist.py", line 50 in draw_wrapper
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/axis.py", line 1163 in draw
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/artist.py", line 50 in draw_wrapper
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/image.py", line 132 in _draw_list_compositing_images
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/axes/_base.py", line 3082 in draw
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/artist.py", line 50 in draw_wrapper
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/image.py", line 132 in _draw_list_compositing_images
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/figure.py", line 2803 in draw
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/artist.py", line 50 in draw_wrapper
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/artist.py", line 73 in draw_wrapper
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/backends/backend_agg.py", line 436 in draw
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/backends/backend_agg.py", line 540 in print_png
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/_api/deprecation.py", line 412 in wrapper
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/backend_bases.py", line 1643 in wrapper
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/backend_bases.py", line 2314 in print_figure
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/figure.py", line 3012 in savefig
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/pyplot.py", line 958 in savefig
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/tests/test_agg.py", line 61 in test_large_single_path_collection
File "/usr/lib/python3/dist-packages/_pytest/python.py", line 183 in pytest_pyfunc_call
File "/usr/lib/python3/dist-packages/pluggy/callers.py", line 187 in _multicall
File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 83 in <lambda>
File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 92 in _hookexec
File "/usr/lib/python3/dist-packages/pluggy/hooks.py", line 286 in __call__
File "/usr/lib/python3/dist-packages/_pytest/python.py", line 1641 in runtest
File "/usr/lib/python3/dist-packages/_pytest/runner.py", line 162 in pytest_runtest_call
File "/usr/lib/python3/dist-packages/pluggy/callers.py", line 187 in _multicall
File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 83 in <lambda>
File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 92 in _hookexec
File "/usr/lib/python3/dist-packages/pluggy/hooks.py", line 286 in __call__
File "/usr/lib/python3/dist-packages/_pytest/runner.py", line 255 in <lambda>
File "/usr/lib/python3/dist-packages/_pytest/runner.py", line 311 in from_call
File "/usr/lib/python3/dist-packages/_pytest/runner.py", line 254 in call_runtest_hook
File "/usr/lib/python3/dist-packages/_pytest/runner.py", line 215 in call_and_report
File "/usr/lib/python3/dist-packages/_pytest/runner.py", line 126 in runtestprotocol
File "/usr/lib/python3/dist-packages/_pytest/runner.py", line 109 in pytest_runtest_protocol
File "/usr/lib/python3/dist-packages/pluggy/callers.py", line 187 in _multicall
File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 83 in <lambda>
File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 92 in _hookexec
File "/usr/lib/python3/dist-packages/pluggy/hooks.py", line 286 in __call__
File "/usr/lib/python3/dist-packages/_pytest/main.py", line 348 in pytest_runtestloop
File "/usr/lib/python3/dist-packages/pluggy/callers.py", line 187 in _multicall
File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 83 in <lambda>
File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 92 in _hookexec
File "/usr/lib/python3/dist-packages/pluggy/hooks.py", line 286 in __call__
File "/usr/lib/python3/dist-packages/_pytest/main.py", line 323 in _main
File "/usr/lib/python3/dist-packages/_pytest/main.py", line 269 in wrap_session
File "/usr/lib/python3/dist-packages/_pytest/main.py", line 316 in pytest_cmdline_main
File "/usr/lib/python3/dist-packages/pluggy/callers.py", line 187 in _multicall
File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 83 in <lambda>
File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 92 in _hookexec
File "/usr/lib/python3/dist-packages/pluggy/hooks.py", line 286 in __call__
File "/usr/lib/python3/dist-packages/_pytest/config/__init__.py", line 162 in main
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/__init__.py", line 1262 in test
File "/<<PKGBUILDDIR>>/build/lib.linux-mips64-3.10/matplotlib/_api/deprecation.py", line 205 in wrapper
File "/<<PKGBUILDDIR>>/tests.py", line 33 in <module>
Extension modules: numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg.lapack_lite, 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, matplotlib._image, _cffi_backend, gi._gi, pvectorc, lxml._elementpath, lxml.etree, PyQt5.QtCore, PyQt5.QtGui, PyQt5.QtWidgets (total: 27)
Segmentation fault
full build log here
Expected outcome
no failure
Additional information
No response
Operating system
Debian
Matplotlib Version
3.5.0
Matplotlib Backend
No response
Python version
3.9.9 and 3.10.0
Jupyter version
No response
Installation
Linux package manager
Activity
jklymak commentedon Nov 29, 2021
This is dying on
test_agg.py::test_large_single_path_collectionwhich says:Looks like we are causing a segfault, so therefore are applying the optimization? This logic looks like it was tweaked in 53d2549 by @tacaswell, so maybe he has some ideas if something was missed?
QuLogic commentedon Nov 30, 2021
That commit didn't change any C code, just made the limits bigger. It's possibly overflowing now.
Can you get a complete backtrace with gdb?
tacaswell commentedon Nov 30, 2021
Due to our minor re-writing of history, github has lost the ability to point to the orign PR: #19343 . The new version of the commit that is likely at fault is d0b5550 . @sandrotosi Can you revert that patch on the broken system?
sandrotosi commentedon Nov 30, 2021
only on mips64el and not on any other architecture? i'm not sure if that's supported by our build tools, i'll investigate
QuLogic commentedon Nov 30, 2021
Have you tried 3.4.3 again? It does not appear to pass the tests either, so I'm not sure this is a regression in Matplotlib.
QuLogic commentedon Nov 30, 2021
The crash is here:
matplotlib/src/_backend_agg.h
Line 658 in 9765379
and I did not look any further than that. Reverting d0b5550 does not fix the crash.
sandrotosi commentedon Dec 1, 2021
(the git reorg makes it kinda tricky to navigate old prs and commit) i just had a look at the previous builds of mpl in Debian, and this was already happening in 3.3.4, then all the other builds from that version until the last one were fine.
Even 3.5.0 built fine once and then failed in a subsequent upload that was basically a no-code change release (enable of sphinx-panels).
It is very possible that the code causing the segfault has been there for a while, but now it looks like other packages have maybe started to stress the same faulty codepath that previously only mpl tests were using.
olebole commentedon Dec 9, 2021
FYI Debian#1001168 (comment) contains a backtrace for this issue, and also a minimal example code by @picca.
sandrotosi commentedon Dec 24, 2021
is there something we (debian) can do to help you figure out what's going on? since we build all matplotlib reverse-dependencies on mips64el too, and with mpl segfaulting there, many of them are also failing, causing quite a bit of a backlog on our end.
thanks!
picca commentedon Dec 24, 2021
tacaswell commentedon Dec 24, 2021
Try also reverting 26e00af ?
Seems trivial, but previously copied paths lost of they should be simplified or not which could in turn be changing details of which c-code gets run which may have brought this out.
Can someone who has access to a mips64 machine bisect based on @picca 's MWE?
Sorry about that, we accidentally merged a whole virtualenv and its removal into our history.
sandrotosi commentedon Dec 27, 2021
just tried reverting 26e00af (and only that commit) and the test suite failed in the same manner.
sandrotosi commentedon Dec 27, 2021
i tested:
3.5.0
3.4.3
3.3.4
3.2.2
all of them sigsegv on the same test.
this becomes evident the problem is somewhere else than mpl, likely numpy as picca mentioned. i'll start looking into that now
sandrotosi commentedon Dec 28, 2021
i've run again that single test in gdb and got
that seems to point to something in
extern/agg24-svnand not numpy? there's no different between 3.4.3 and 3.5.0 in that directory, so maybe it's another library matplotlib includes that we should be looking at, but which one?sandrotosi commentedon Dec 28, 2021
continuing with the investigation, i checked what packages were different between the last good build (
-) and the first one that started SIGSEGVing (+) and here's an extract of the relevant ones (the full diff can be obtained with this command:diff -u <(curl -s 'https://buildd.debian.org/status/fetch.php?pkg=matplotlib&arch=mips64el&ver=3.3.4-2&stamp=1633211581&raw=1') <(curl -s 'https://buildd.debian.org/status/fetch.php?pkg=matplotlib&arch=mips64el&ver=3.3.4-2%2Bb1&stamp=1637459674&raw=1'), packages diff starts searching the string Buildinfo):does any of them ring a bell to you guys?
[-][Bug]: 3.5.0 on mips64el: segfault when running on tests[/-][+][Bug]: 3.5.1 on mips64el: segfault when running on tests[/+]sandrotosi commentedon Jan 3, 2022
I've upgraded matplotlib to 3.5.1 in Debian, and this is the confirmation the test suite still SIGSEGVs when running on mips64el; full build log here
picca commentedon Jan 3, 2022
Hello I investigated a bit more and compiled with gcc-10 and no-lto
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1001168#72
no segfault with gcc-10 and no-lto.
QuLogic commentedon Jan 5, 2022
Maybe; probably, even?
There is some text in the test, but that seems unlikely if everything else is fine.
Highly unlikely.
Also doubtful.
Agg is in C++, so maybe, but I don't think it uses very much of the standard library.
Maybe, insomuch as libc affects everything.
Nope.
Maybe.
sandrotosi commentedon Jan 29, 2022
this turned out to be a bug in gcc-11 on mips64* architectures (
-O1/-O2may generated bad code, while-O0/-O3appear to be fine), which in debian we worked around by passing-O3to gccQuLogic commentedon Jan 31, 2022
I'll close this then as an upstream issue.
yangfl commentedon Mar 14, 2022
FYI following issue: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104914