Skip to content

Segmentation fault inside _backend_agg.so #7050

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

Closed
ngoldbaum opened this issue Sep 6, 2016 · 7 comments
Closed

Segmentation fault inside _backend_agg.so #7050

ngoldbaum opened this issue Sep 6, 2016 · 7 comments

Comments

@ngoldbaum
Copy link
Contributor

ngoldbaum commented Sep 6, 2016

This came up in the context of the yt test suite. To reproduce it using the test script I've include here requires yt 3.3.1 or the latest development version of yt to be installed. We regularly trigger this during our test suite which uses matplotlib 1.5.1.

import numpy as np
import yt
from yt.testing import fake_tetrahedral_ds
from yt.testing import fake_hexahedral_ds

np.random.seed(0x4d3d3d3)

ds = fake_hexahedral_ds()
idir = 2
for field in ds.field_list:
    sl = yt.SlicePlot(ds, idir, field)
    sl.annotate_mesh_lines()
    sl.save()

The stack trace I get back from the apple crash reporter consists only of calls to (including just the first three)

0   _backend_agg.so                   0x0000000148a37cbf agg::rasterizer_cells_aa<agg::cell_aa>::line(int, int, int, int) + 31
1   _backend_agg.so                   0x0000000148a37cfd agg::rasterizer_cells_aa<agg::cell_aa>::line(int, int, int, int) + 93
2   _backend_agg.so                   0x0000000148a37cfd agg::rasterizer_cells_aa<agg::cell_aa>::line(int, int, int, int) + 93

In addition, we were able to capture this in GDB and get a python traceback as well: https://gist.github.com/ngoldbaum/7538f71644ec4248b41d9d0d1f6bef34

Note that the seg fault does not happen every time you run the test script. I've been able to trigger it by running e.g. this bash for loop:

for i in {0..100} ; do python test.py ; echo $i ; done

Finally, I tried updating matplotlib to 2.0b3 from the prerelease wheels on pypi, and that seems to have fixed it? I'm going to try running the test script 1000 times to see if I can reproduce on matplotlib 2.0b3, but if I can't then maybe this is already fixed upstream.

@ngoldbaum
Copy link
Contributor Author

So I can't seem to reproduce this on the latest version of matplotlib, but since I still haven't identified how this was fixed I'm going to leave this open. It seems vaguely related to the discussion in this comment: #3626 (comment)

@mdboom do you have any insight into this one?

@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Sep 7, 2016
@tacaswell
Copy link
Member

Also asked in gitter, what is yt.SlicePlot doing under the hood?

@Xarthisius
Copy link
Contributor

Further down the stack:

#37232 0x00007f6d11f8ba70 in agg::rasterizer_cells_aa<agg::cell_aa>::line (this=this@entry=0x13192220, x1=x1@entry=-2147483648, y1=y1@entry=7680, x2=x2@entry=536913444, y2=y2@entry=66733)
    at extern/agg24-svn/include/agg_rasterizer_cells_aa.h:330
#37233 0x00007f6d11f8ba70 in agg::rasterizer_cells_aa<agg::cell_aa>::line (this=this@entry=0x13192220, x1=x1@entry=-2147483648, y1=y1@entry=7680, x2=x2@entry=-1073656760, y2=y2@entry=125786)
    at extern/agg24-svn/include/agg_rasterizer_cells_aa.h:330
#37234 0x00007f6d11f8ba70 in agg::rasterizer_cells_aa<agg::cell_aa>::line (this=0x13192220, x1=-2147483648, y1=7680, x2=170129, y2=243893) at extern/agg24-
#37235 0x00007f6d11f9c4d6 in agg::rasterizer_sl_clip<agg::ras_conv_dbl>::line_to<agg::rasterizer_cells_aa<agg::cell_aa> > (this=this@entry=0x131922a0, ras=..., x2=664.56806133079476, 
    y2=952.70854352328502) at extern/agg24-svn/include/agg_rasterizer_sl_clip.h:242
#37236 0x00007f6d11f8ffa3 in agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip<agg::ras_conv_dbl> >::close_polygon (this=0x13192220) at extern/agg24-svn/include/agg_rasterizer_scanline_aa.h:333
#37237 0x00007f6d11fa3ebc in agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip<agg::ras_conv_dbl> >::add_path<agg::conv_stroke<agg::conv_curve<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<py::PathIterator> > > >, agg::curve3, agg::curve4>, agg::null_markers> > (path_id=0, vs=..., this=0x13192220) at extern/agg24-svn/include/agg_rasterizer_scanline_aa.h:169
#37238 RendererAgg::_draw_path<agg::conv_curve<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<py::PathIterator, agg::trans_affine> > > >, agg::curve3, agg::curve4> > (
    this=this@entry=0x13192090, path=..., has_clippath=has_clippath@entry=false, face=..., gc=...) at src/_backend_agg.h:423
#37239 0x00007f6d11f924d3 in RendererAgg::_draw_path_collection_generic<py::PathIterator, py::PathGenerator, numpy::array_view<double const, 3>, numpy::array_view<double const, 2>, numpy::array_view<double const, 2>, numpy::array_view<double const, 1>, numpy::array_view<unsigned char const, 1> > (has_curves=1, check_snap=1, offset_position=OFFSET_POSITION_FIGURE, antialiaseds=..., 
    linestyles=std::vector of length 1, capacity 1 = {...}, linewidths=..., edgecolors=..., facecolors=..., offset_trans=..., offsets=..., transforms=..., path_generator=..., clippath_trans=..., 
    clippath=..., cliprect=..., master_transform=..., gc=..., this=0x13192090) at src/_backend_agg.h:1022
#37240 RendererAgg::draw_path_collection<py::PathGenerator, numpy::array_view<double const, 3>, numpy::array_view<double const, 2>, numpy::array_view<double const, 2>, numpy::array_view<double const, 1>, numpy::array_view<unsigned char const, 1> > (offset_position=<optimized out>, antialiaseds=..., linestyles=std::vector of length 1, capacity 1 = {...}, linewidths=..., edgecolors=..., 
    facecolors=..., offset_trans=..., offsets=..., transforms=..., path=..., master_transform=..., gc=..., this=0x13192090) at src/_backend_agg.h:1061
#37241 PyRendererAgg_draw_path_collection (self=<optimized out>, args=<optimized out>, kwds=<optimized out>) at src/_backend_agg_wrapper.cpp:369
#37242 0x00007f6d775aa48e in ext_do_call (nk=<optimized out>, na=<optimized out>, flags=<optimized out>, pp_stack=0x7ffffcb7e348, 
    func=<built-in method draw_path_collection of matplotlib.backends._backend_agg.RendererAgg object at remote 0x7f6d10a94c90>)
    at /var/tmp/portage/dev-lang/python-2.7.11/work/Python-2.7.11/Python/ceval.c:4660
#37243 PyEval_EvalFrameEx (
    f=f@entry=Frame 0x58275570, for file /usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py, line 126, in draw_path_collection (self=<RendererAgg(_text2path=<TextToPath(_adobe_standard_encoding=None, _ps_fontd=<maxdict(maxsize=50, _killkeys=[]) at remote 0x7f6d091f3d08>, tex_font_map=None, _texmanager=None, mathtext_parser=<MathTextParser(_cache=<maxdict(maxsize=50, _killkeys=[]) at remote 0x7f6d091f33c8>, _output=u'path') at remote 0x7f6d10aac750>) at remote 0x7f6d10aacd90>, copy_from_bbox=<built-in method copy_from_bbox of matplotlib.backends._backend_agg.RendererAgg object at remote 0x7f6d10a94c90>, get_content_extents=<built-in method get_content_extents of matplotlib.backends._backend_agg.RendererAgg object at remote 0x7f6d10a94c90>, draw_gouraud_triangles=<built-in method draw_gouraud_triangles of matplotlib.backends._backend_agg.RendererAgg object at remote 0x7f6d10a94c90>, draw_image=<built-in method draw_image of matplotlib.backends._backend_agg.RendererAgg object at remote 0x7f6d10a94c90>, heig...(truncated), throwflag=throwflag@entry=0) at /var/tmp/portage/dev-lang/python-2.7.11/work/Python-2.7.11/Python/ceval.c:3026

@ngoldbaum
Copy link
Contributor Author

ngoldbaum commented Sep 7, 2016

It's creating an imshow plot (with an image of a slice through an unstructured mesh dataset), and then drawing lines on top of the image to mark the boundaries of the mesh cells using a LineCollection. Given the traceback, I guess the problem is in how agg is drawing the lines.

@QuLogic QuLogic modified the milestones: 2.0.1 (next bug fix release), 2.0.2 (next bug fix release) May 3, 2017
@anntzer
Copy link
Contributor

anntzer commented Sep 16, 2017

Closing on the basis that it appears to be fixed in 2.0, but feel free to request a reopen if this is not the case.

@anntzer anntzer closed this as completed Sep 16, 2017
@efiring
Copy link
Member

efiring commented Sep 7, 2018

Maybe related: we are getting occasional segfaults running a plot script on our shipboard systems. The dmesg errors all look like this:

kilomoana/working/dmesg.txt:[5856329.820870] run_3dayplots_m[5088]: segfault at 7ffcf0c42ff4 ip 00007f9c2683ab9d sp 00007ffcf0c42fd0 error 6 in _backend_agg.cpython-36m-x86_64-linux-gnu.so[7f9c26827000+3f000]

We have seen this with mpl 2.1.1, Python 3.6.5 (xubuntu 18.04) and with mpl 1.5.1, Python 2.7.12.

@efiring efiring reopened this Sep 7, 2018
@QuLogic
Copy link
Member

QuLogic commented Jul 23, 2020

I'm going to close this again. The original issue is fixed and the other reports are on unsupported versions.

@QuLogic QuLogic closed this as completed Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants