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

Possible memory leaks reported by valgrind #2354

Closed
mmokrejs opened this issue Aug 28, 2013 · 11 comments
Closed

Possible memory leaks reported by valgrind #2354

mmokrejs opened this issue Aug 28, 2013 · 11 comments

Comments

@mmokrejs
Copy link

While chasing for places where an unknown application overwrites some python-interpreter-owned regions (leading to Segmentation Faults or Fatal Python Interpreter errors) I ran valgring on my application (well, used cython to convert it to C and then used "gcc -ggdb" to get the binary with full debug). It between others uses matplotlib-1.2.1. I would be happy to re-test a patch for 1.2.1 (I have issues when compiling/installing 1.3.0 so I won't go that way at the moment).

==5435== 3,763,200 bytes in 1 blocks are possibly lost in loss record 1,915 of 1,915
==5435== at 0x4C2B8F7: operator new[](unsigned long) (vg_replace_malloc.c:363)
==5435== by 0x1146DD20: RendererAgg::RendererAgg(unsigned int, unsigned int, double, int) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1147B801: _backend_agg_module::new_renderer(Py::Tuple const&, Py::Dict const&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1147BF39: Py::ExtensionModule<_backend_agg_module>::invoke_method_keyword(void*, Py::Tuple const&, Py::Dict const&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1146342D: method_keyword_call_handler (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x4EEB94F: PyCFunction_Call (methodobject.c:85)
==5435== by 0x4F928EF: do_call (ceval.c:4236)
==5435== by 0x4F91C44: call_function (ceval.c:4044)
==5435== by 0x4F8C52B: PyEval_EvalFrameEx (ceval.c:2666)
==5435== by 0x4F8EF61: PyEval_EvalCodeEx (ceval.c:3253)
==5435== by 0x4EC7925: function_call (funcobject.c:526)
==5435== by 0x4E868A3: PyObject_Call (abstract.c:2529)

==5435== 1,123 bytes in 1 blocks are possibly lost in loss record 1,559 of 1,915
==5435== at 0x4C2B8F7: operator new[](unsigned long) (vg_replace_malloc.c:363)
==5435== by 0x1148E586: void agg::render_scanlinesagg::rasterizer_scanline_aa<agg::rasterizer_sl_clip<agg::ras_conv_dbl >, agg::scanline_p8, agg::renderer_scanline_bin_solid<agg::renderer_base<agg::pixfmt_alpha_blend_rgba<agg::blender_rgba<agg::rgba8, agg::order_rgba>, agg::row_accessor, unsigned int> > > >(agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >&, agg::scanline_p8&, agg::renderer_scanline_bin_solid<agg::renderer_base<agg::pixfmt_alpha_blend_rgba<agg::blender_rgba<agg::rgba8, agg::order_rgba>, agg::row_accessor, unsigned int> > >&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1149232E: void RendererAgg::_draw_path<agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4> >(agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4>&, bool, std::pair<bool, agg::rgba> const&, GCAgg const&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x11474852: RendererAgg::draw_path(Py::Tuple const&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1147CE78: Py::PythonExtension::method_varargs_call_handler(object, object) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x4EEB935: PyCFunction_Call (methodobject.c:81)
==5435== by 0x4F91A27: call_function (ceval.c:4021)
==5435== by 0x4F8C52B: PyEval_EvalFrameEx (ceval.c:2666)
==5435== by 0x4F8EF61: PyEval_EvalCodeEx (ceval.c:3253)
==5435== by 0x4F9206D: fast_function (ceval.c:4117)
==5435== by 0x4F91C28: call_function (ceval.c:4042)
==5435== by 0x4F8C52B: PyEval_EvalFrameEx (ceval.c:2666)

==5435== 65,536 bytes in 1 blocks are possibly lost in loss record 1,817 of 1,915
==5435== at 0x4C2B8F7: operator new[](unsigned long) (vg_replace_malloc.c:363)
==5435== by 0x1148792E: agg::rasterizer_cells_aaagg::cell_aa::allocate_block() (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1148CD48: agg::rasterizer_cells_aaagg::cell_aa::line(int, int, int, int) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1148D5C0: void agg::rasterizer_sl_clipagg::ras_conv_dbl::line_toagg::rasterizer_cells_aa<agg::cell_aa >(agg::rasterizer_cells_aaagg::cell_aa&, double, double) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1148DB43: agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >::add_vertex(double, double, unsigned int) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1148E1C5: void agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >::add_path<agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4> >(agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4>&, unsigned int) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x11490E5F: void RendererAgg::_draw_path<agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4> >(agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4>&, bool, std::pair<bool, agg::rgba> const&, GCAgg const&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x11474852: RendererAgg::draw_path(Py::Tuple const&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1147CE78: Py::PythonExtension::method_varargs_call_handler(object, object) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x4EEB935: PyCFunction_Call (methodobject.c:81)
==5435== by 0x4F91A27: call_function (ceval.c:4021)
==5435== by 0x4F8C52B: PyEval_EvalFrameEx (ceval.c:2666)

==5435== 22,496 bytes in 1 blocks are possibly lost in loss record 1,794 of 1,915
==5435== at 0x4C2C067: operator new(unsigned long) (vg_replace_malloc.c:298)
==5435== by 0x1147B7E7: _backend_agg_module::new_renderer(Py::Tuple const&, Py::Dict const&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1147BF39: Py::ExtensionModule<_backend_agg_module>::invoke_method_keyword(void*, Py::Tuple const&, Py::Dict const&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1146342D: method_keyword_call_handler (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x4EEB94F: PyCFunction_Call (methodobject.c:85)
==5435== by 0x4F928EF: do_call (ceval.c:4236)
==5435== by 0x4F91C44: call_function (ceval.c:4044)
==5435== by 0x4F8C52B: PyEval_EvalFrameEx (ceval.c:2666)
==5435== by 0x4F8EF61: PyEval_EvalCodeEx (ceval.c:3253)
==5435== by 0x4EC7925: function_call (funcobject.c:526)
==5435== by 0x4E868A3: PyObject_Call (abstract.c:2529)
==5435== by 0x4EA2A8E: instancemethod_call (classobject.c:2602)

==5435== 17,968 bytes in 1 blocks are possibly lost in loss record 1,786 of 1,915
==5435== at 0x4C2B8F7: operator new[](unsigned long) (vg_replace_malloc.c:363)
==5435== by 0x1148E564: void agg::render_scanlinesagg::rasterizer_scanline_aa<agg::rasterizer_sl_clip<agg::ras_conv_dbl >, agg::scanline_p8, agg::renderer_scanline_bin_solid<agg::renderer_base<agg::pixfmt_alpha_blend_rgba<agg::blender_rgba<agg::rgba8, agg::order_rgba>, agg::row_accessor, unsigned int> > > >(agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >&, agg::scanline_p8&, agg::renderer_scanline_bin_solid<agg::renderer_base<agg::pixfmt_alpha_blend_rgba<agg::blender_rgba<agg::rgba8, agg::order_rgba>, agg::row_accessor, unsigned int> > >&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1149232E: void RendererAgg::_draw_path<agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4> >(agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4>&, bool, std::pair<bool, agg::rgba> const&, GCAgg const&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x11474852: RendererAgg::draw_path(Py::Tuple const&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1147CE78: Py::PythonExtension::method_varargs_call_handler(object, object) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x4EEB935: PyCFunction_Call (methodobject.c:81)
==5435== by 0x4F91A27: call_function (ceval.c:4021)
==5435== by 0x4F8C52B: PyEval_EvalFrameEx (ceval.c:2666)
==5435== by 0x4F8EF61: PyEval_EvalCodeEx (ceval.c:3253)
==5435== by 0x4F9206D: fast_function (ceval.c:4117)
==5435== by 0x4F91C28: call_function (ceval.c:4042)
==5435== by 0x4F8C52B: PyEval_EvalFrameEx (ceval.c:2666)

==5435== 13,568 bytes in 1 blocks are possibly lost in loss record 1,778 of 1,915
==5435== at 0x4C2B8F7: operator new[](unsigned long) (vg_replace_malloc.c:363)
==5435== by 0x11487D85: agg::rasterizer_cells_aaagg::cell_aa::sort_cells() (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1148E51D: void agg::render_scanlinesagg::rasterizer_scanline_aa<agg::rasterizer_sl_clip<agg::ras_conv_dbl >, agg::scanline_p8, agg::renderer_scanline_bin_solid<agg::renderer_base<agg::pixfmt_alpha_blend_rgba<agg::blender_rgba<agg::rgba8, agg::order_rgba>, agg::row_accessor, unsigned int> > > >(agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >&, agg::scanline_p8&, agg::renderer_scanline_bin_solid<agg::renderer_base<agg::pixfmt_alpha_blend_rgba<agg::blender_rgba<agg::rgba8, agg::order_rgba>, agg::row_accessor, unsigned int> > >&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1149232E: void RendererAgg::_draw_path<agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4> >(agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4>&, bool, std::pair<bool, agg::rgba> const&, GCAgg const&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x11474852: RendererAgg::draw_path(Py::Tuple const&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1147CE78: Py::PythonExtension::method_varargs_call_handler(object, object) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x4EEB935: PyCFunction_Call (methodobject.c:81)
==5435== by 0x4F91A27: call_function (ceval.c:4021)
==5435== by 0x4F8C52B: PyEval_EvalFrameEx (ceval.c:2666)
==5435== by 0x4F8EF61: PyEval_EvalCodeEx (ceval.c:3253)
==5435== by 0x4F9206D: fast_function (ceval.c:4117)
==5435== by 0x4F91C28: call_function (ceval.c:4042)

==5435== 11,000 bytes in 11 blocks are possibly lost in loss record 1,755 of 1,915
==5435== at 0x4C2C63B: malloc (vg_replace_malloc.c:270)
==5435== by 0x4EF3742: PyObject_Malloc (obmalloc.c:943)
==5435== by 0x4EF41CD: _PyObject_DebugMallocApi (obmalloc.c:1445)
==5435== by 0x4EF40BF: _PyMem_DebugMalloc (obmalloc.c:1395)
==5435== by 0x4EBC491: fill_free_list (floatobject.c:43)
==5435== by 0x4EBC7C0: PyFloat_FromDouble (floatobject.c:146)
==5435== by 0xE0FF3B4: FT2Font::set_text(Py::Tuple const&, Py::Dict const&) (in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0xE0FFCC3: _callKeywordsMethod__set_text(object, object, _object*) (in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0x4EEB94F: PyCFunction_Call (methodobject.c:85)
==5435== by 0x4F928EF: do_call (ceval.c:4236)
==5435== by 0x4F91C44: call_function (ceval.c:4044)
==5435== by 0x4F8C52B: PyEval_EvalFrameEx (ceval.c:2666)

==5435== 6,856 bytes in 1 blocks are possibly lost in loss record 1,735 of 1,915
==5435== at 0x4C2B8F7: operator new[](unsigned long) (vg_replace_malloc.c:363)
==5435== by 0x11487DA3: agg::rasterizer_cells_aaagg::cell_aa::sort_cells() (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1148E51D: void agg::render_scanlinesagg::rasterizer_scanline_aa<agg::rasterizer_sl_clip<agg::ras_conv_dbl >, agg::scanline_p8, agg::renderer_scanline_bin_solid<agg::renderer_base<agg::pixfmt_alpha_blend_rgba<agg::blender_rgba<agg::rgba8, agg::order_rgba>, agg::row_accessor, unsigned int> > > >(agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >&, agg::scanline_p8&, agg::renderer_scanline_bin_solid<agg::renderer_base<agg::pixfmt_alpha_blend_rgba<agg::blender_rgba<agg::rgba8, agg::order_rgba>, agg::row_accessor, unsigned int> > >&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1149232E: void RendererAgg::_draw_path<agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4> >(agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4>&, bool, std::pair<bool, agg::rgba> const&, GCAgg const&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x11474852: RendererAgg::draw_path(Py::Tuple const&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1147CE78: Py::PythonExtension::method_varargs_call_handler(object, object) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x4EEB935: PyCFunction_Call (methodobject.c:81)
==5435== by 0x4F91A27: call_function (ceval.c:4021)
==5435== by 0x4F8C52B: PyEval_EvalFrameEx (ceval.c:2666)
==5435== by 0x4F8EF61: PyEval_EvalCodeEx (ceval.c:3253)
==5435== by 0x4F9206D: fast_function (ceval.c:4117)
==5435== by 0x4F91C28: call_function (ceval.c:4042)

==5435== 3,000 bytes in 3 blocks are possibly lost in loss record 1,646 of 1,915
==5435== at 0x4C2C63B: malloc (vg_replace_malloc.c:270)
==5435== by 0x4EF3742: PyObject_Malloc (obmalloc.c:943)
==5435== by 0x4EF41CD: _PyObject_DebugMallocApi (obmalloc.c:1445)
==5435== by 0x4EF40BF: _PyMem_DebugMalloc (obmalloc.c:1395)
==5435== by 0x4EBC491: fill_free_list (floatobject.c:43)
==5435== by 0x4EBC7C0: PyFloat_FromDouble (floatobject.c:146)
==5435== by 0xE0FF2D2: FT2Font::set_text(Py::Tuple const&, Py::Dict const&) (in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0xE0FFCC3: _callKeywordsMethod__set_text(object, object, _object*) (in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0x4EEB94F: PyCFunction_Call (methodobject.c:85)
==5435== by 0x4F928EF: do_call (ceval.c:4236)
==5435== by 0x4F91C44: call_function (ceval.c:4044)
==5435== by 0x4F8C52B: PyEval_EvalFrameEx (ceval.c:2666)

==5435== 2,048 bytes in 1 blocks are possibly lost in loss record 1,629 of 1,915
==5435== at 0x4C2B8F7: operator new[](unsigned long) (vg_replace_malloc.c:363)
==5435== by 0x11487986: agg::rasterizer_cells_aaagg::cell_aa::allocate_block() (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1148CD48: agg::rasterizer_cells_aaagg::cell_aa::line(int, int, int, int) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1148D5C0: void agg::rasterizer_sl_clipagg::ras_conv_dbl::line_toagg::rasterizer_cells_aa<agg::cell_aa >(agg::rasterizer_cells_aaagg::cell_aa&, double, double) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1148DB43: agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >::add_vertex(double, double, unsigned int) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1148E1C5: void agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >::add_path<agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4> >(agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4>&, unsigned int) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x11490E5F: void RendererAgg::_draw_path<agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4> >(agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4>&, bool, std::pair<bool, agg::rgba> const&, GCAgg const&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x11474852: RendererAgg::draw_path(Py::Tuple const&) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1147CE78: Py::PythonExtension::method_varargs_call_handler(object, object) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x4EEB935: PyCFunction_Call (methodobject.c:81)
==5435== by 0x4F91A27: call_function (ceval.c:4021)
==5435== by 0x4F8C52B: PyEval_EvalFrameEx (ceval.c:2666)

==5435== 2,000 bytes in 2 blocks are possibly lost in loss record 1,625 of 1,915
==5435== at 0x4C2C63B: malloc (vg_replace_malloc.c:270)
==5435== by 0x4EF3742: PyObject_Malloc (obmalloc.c:943)
==5435== by 0x4EF41CD: _PyObject_DebugMallocApi (obmalloc.c:1445)
==5435== by 0x4EF40BF: _PyMem_DebugMalloc (obmalloc.c:1395)
==5435== by 0x4EC814D: fill_free_list (intobject.c:52)
==5435== by 0x4EC8237: PyInt_FromLong (intobject.c:104)
==5435== by 0xE0EC16F: Py::Int::Int(long) [clone .constprop.109](in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0xE0F2BCB: FT2Font::get_width_height(Py::Tuple const&) (in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0xE0F2D74: _callVarArgsMethod__get_width_height(object, object, _object*) (in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0x4EEB935: PyCFunction_Call (methodobject.c:81)
==5435== by 0x4F91A27: call_function (ceval.c:4021)
==5435== by 0x4F8C52B: PyEval_EvalFrameEx (ceval.c:2666)

==5435== 1,000 bytes in 1 blocks are possibly lost in loss record 1,551 of 1,915
==5435== at 0x4C2C63B: malloc (vg_replace_malloc.c:270)
==5435== by 0x4EF3742: PyObject_Malloc (obmalloc.c:943)
==5435== by 0x4EF41CD: _PyObject_DebugMallocApi (obmalloc.c:1445)
==5435== by 0x4EF40BF: _PyMem_DebugMalloc (obmalloc.c:1395)
==5435== by 0x4EC814D: fill_free_list (intobject.c:52)
==5435== by 0x4EC8237: PyInt_FromLong (intobject.c:104)
==5435== by 0xE0EC16F: Py::Int::Int(long) [clone .constprop.109](in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0xE0F2921: FT2Font::get_descent(Py::Tuple const&) (in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0xE0F29E4: _callVarArgsMethod__get_descent(object, object, _object*) (in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0x4EEB935: PyCFunction_Call (methodobject.c:81)
==5435== by 0x4F91A27: call_function (ceval.c:4021)
==5435== by 0x4F8C52B: PyEval_EvalFrameEx (ceval.c:2666)

==5435== 800 bytes in 1 blocks are possibly lost in loss record 1,514 of 1,915
==5435== at 0x4C2C63B: malloc (vg_replace_malloc.c:270)
==5435== by 0x4EF3742: PyObject_Malloc (obmalloc.c:943)
==5435== by 0x4EF41CD: _PyObject_DebugMallocApi (obmalloc.c:1445)
==5435== by 0x4EF40BF: _PyMem_DebugMalloc (obmalloc.c:1395)
==5435== by 0x4EE27A6: dictresize (dictobject.c:643)
==5435== by 0x4EE2CE4: dict_set_item_by_hash_or_entry (dictobject.c:788)
==5435== by 0x4EE2DED: PyDict_SetItem (dictobject.c:818)
==5435== by 0x4EE41FB: dict_ass_sub (dictobject.c:1211)
==5435== by 0x4E7FDF4: PyObject_SetItem (abstract.c:173)
==5435== by 0xE101784: Py::MapBasePy::Object::setItem(Py::Object const&, Py::Object const&) (in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0xE0EBEEB: Py::maprefPy::Object::operator=(Py::Object const&) [clone .constprop.106](in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0xE0EC68F: FT2Font::setattro(Py::String const&, Py::Object const&) (in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)

==5435== 328 bytes in 1 blocks are possibly lost in loss record 1,240 of 1,915
==5435== at 0x4C2C63B: malloc (vg_replace_malloc.c:270)
==5435== by 0x4EF3742: PyObject_Malloc (obmalloc.c:943)
==5435== by 0x4EF41CD: _PyObject_DebugMallocApi (obmalloc.c:1445)
==5435== by 0x4EF4124: _PyObject_DebugMalloc (obmalloc.c:1412)
==5435== by 0x4FDF6A8: _PyObject_GC_Malloc (gcmodule.c:1499)
==5435== by 0x4FDF754: _PyObject_GC_New (gcmodule.c:1521)
==5435== by 0x4EE1678: PyDict_New (dictobject.c:277)
==5435== by 0x4F220BD: PyType_Ready (typeobject.c:4034)
==5435== by 0xE106C3C: Py::PythonType::readyType() (in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0xE0EF26F: Glyph::init_type() (in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0xE0F9EE6: ft2font_module::ft2font_module() (in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0xE0FBD3C: initft2font (in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)

==5435== 48 bytes in 1 blocks are possibly lost in loss record 792 of 1,915
==5435== at 0x4C2C067: operator new(unsigned long) (vg_replace_malloc.c:298)
==5435== by 0x114609C1: Py::ExtensionModuleBase::initialize(char const_) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1147F7FD: Py::ExtensionModule<backend_agg_module>::initialize(char const) (in /usr/lib64/python2.7/site-packages/matplotlib/backends/_backend_agg.so)
==5435== by 0x1147079B: init_backend_agg (in /usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.so)
==5435== by 0x4FB3FD9: PyImport_LoadDynamicModule (importdl.c:53)
==5435== by 0x4FAFDDB: load_module (import.c:1915)
==5435== by 0x4FB21A4: import_submodule (import.c:2700)
==5435== by 0x4FB16C1: load_next (import.c:2515)
==5435== by 0x4FB0829: import_module_level (import.c:2232)
==5435== by 0x4FB0D57: PyImport_ImportModuleLevel (import.c:2288)
==5435== by 0x4F7A6A2: builtin___import
(bltinmodule.c:49)
==5435== by 0x4EEB94F: PyCFunction_Call (methodobject.c:85)

==5435== 48 bytes in 1 blocks are possibly lost in loss record 787 of 1,915
==5435== at 0x4C2C067: operator new(unsigned long) (vg_replace_malloc.c:298)
==5435== by 0xE10A6C1: Py::ExtensionModuleBase::initialize(char const_) (in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0xE1032FD: Py::ExtensionModule<ft2font_module>::initialize(char const_) (in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0xE0F9EFA: ft2font_module::ft2font_module() (in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0xE0FBD3C: initft2font (in /usr/lib64/python2.7/site-packages/matplotlib/ft2font.so)
==5435== by 0x4FB3FD9: PyImport_LoadDynamicModule (importdl.c:53)
==5435== by 0x4FAFDDB: load_module (import.c:1915)
==5435== by 0x4FB21A4: import_submodule (import.c:2700)
==5435== by 0x4FB1CD8: ensure_fromlist (import.c:2606)
==5435== by 0x4FB0C74: import_module_level (import.c:2269)
==5435== by 0x4FB0D57: PyImport_ImportModuleLevel (import.c:2288)
==5435== by 0x4F7A6A2: builtin___import
_ (bltinmodule.c:49)

==5435==
==5435== 48 bytes in 1 blocks are possibly lost in loss record 788 of 1,915
==5435== at 0x4C2C067: operator new(unsigned long) (vg_replace_malloc.c:298)
==5435== by 0xFB2EF11: Py::ExtensionModuleBase::initialize(char const_) (in /usr/lib64/python2.7/site-packages/matplotlib/_png.so)
==5435== by 0xFB2748D: Py::ExtensionModule<png_module>::initialize(char const) (in /usr/lib64/python2.7/site-packages/matplotlib/_png.so)
==5435== by 0xFB256D9: init_png (in /usr/lib64/python2.7/site-packages/matplotlib/png.so)
==5435== by 0x4FB3FD9: PyImport_LoadDynamicModule (importdl.c:53)
==5435== by 0x4FAFDDB: load_module (import.c:1915)
==5435== by 0x4FB21A4: import_submodule (import.c:2700)
==5435== by 0x4FB16C1: load_next (import.c:2515)
==5435== by 0x4FB0829: import_module_level (import.c:2232)
==5435== by 0x4FB0D57: PyImport_ImportModuleLevel (import.c:2288)
==5435== by 0x4F7A6A2: builtin___import
(bltinmodule.c:49)
==5435== by 0x4EEB94F: PyCFunction_Call (methodobject.c:85)
==5435==

==5435== 48 bytes in 1 blocks are possibly lost in loss record 789 of 1,915
==5435== at 0x4C2C067: operator new(unsigned long) (vg_replace_malloc.c:298)
==5435== by 0x105B5CE1: Py::ExtensionModuleBase::initialize(char const_) (in /usr/lib64/python2.7/site-packages/matplotlib/_image.so)
==5435== by 0x105A7CBD: Py::ExtensionModule<image_module>::initialize(char const) (in /usr/lib64/python2.7/site-packages/matplotlib/_image.so)
==5435== by 0x105ABFE5: _image_module::_image_module() (in /usr/lib64/python2.7/site-packages/matplotlib/_image.so)
==5435== by 0x1059EE74: init_image (in /usr/lib64/python2.7/site-packages/matplotlib/image.so)
==5435== by 0x4FB3FD9: PyImport_LoadDynamicModule (importdl.c:53)
==5435== by 0x4FAFDDB: load_module (import.c:1915)
==5435== by 0x4FB21A4: import_submodule (import.c:2700)
==5435== by 0x4FB16C1: load_next (import.c:2515)
==5435== by 0x4FB0829: import_module_level (import.c:2232)
==5435== by 0x4FB0D57: PyImport_ImportModuleLevel (import.c:2288)
==5435== by 0x4F7A6A2: builtin___import
(bltinmodule.c:49)
==5435==

==5435== 48 bytes in 1 blocks are possibly lost in loss record 790 of 1,915
==5435== at 0x4C2C067: operator new(unsigned long) (vg_replace_malloc.c:298)
==5435== by 0x10A0F341: Py::ExtensionModuleBase::initialize(char const_) (in /usr/lib64/python2.7/site-packages/matplotlib/tri.so)
==5435== by 0x10A02EBD: Py::ExtensionModule::initialize(char const
) (in /usr/lib64/python2.7/site-packages/matplotlib/_tri.so)
==5435== by 0x109FEF3E: TriModule::TriModule() (in /usr/lib64/python2.7/site-packages/matplotlib/_tri.so)
==5435== by 0x109FF10F: init_tri (in /usr/lib64/python2.7/site-packages/matplotlib/tri.so)
==5435== by 0x4FB3FD9: PyImport_LoadDynamicModule (importdl.c:53)
==5435== by 0x4FAFDDB: load_module (import.c:1915)
==5435== by 0x4FB21A4: import_submodule (import.c:2700)
==5435== by 0x4FB16C1: load_next (import.c:2515)
==5435== by 0x4FB0829: import_module_level (import.c:2232)
==5435== by 0x4FB0D57: PyImport_ImportModuleLevel (import.c:2288)
==5435== by 0x4F7A6A2: builtin___import
(bltinmodule.c:49)

==5435== 48 bytes in 1 blocks are possibly lost in loss record 786 of 1,915
==5435== at 0x4C2C067: operator new(unsigned long) (vg_replace_malloc.c:298)
==5435== by 0xD96B311: Py::ExtensionModuleBase::initialize(char const_) (in /usr/lib64/python2.7/site-packages/matplotlib/_path.so)
==5435== by 0xD98568D: Py::ExtensionModule<path_module>::initialize(char const) (in /usr/lib64/python2.7/site-packages/matplotlib/_path.so)
==5435== by 0xD98B23C: _path_module::_path_module() (in /usr/lib64/python2.7/site-packages/matplotlib/_path.so)
==5435== by 0xD98468C: init_path (in /usr/lib64/python2.7/site-packages/matplotlib/path.so)
==5435== by 0x4FB3FD9: PyImport_LoadDynamicModule (importdl.c:53)
==5435== by 0x4FAFDDB: load_module (import.c:1915)
==5435== by 0x4FB21A4: import_submodule (import.c:2700)
==5435== by 0x4FB16C1: load_next (import.c:2515)
==5435== by 0x4FB0829: import_module_level (import.c:2232)
==5435== by 0x4FB0D57: PyImport_ImportModuleLevel (import.c:2288)
==5435== by 0x4F7A6A2: builtin___import
(bltinmodule.c:49)

@efiring
Copy link
Member

efiring commented Aug 29, 2013

Blindly running valgrind on python is not informative. See, for example, http://www.j-david.net/2012/07/python-running-valgrind-on-a-c-extension.html.

@efiring efiring closed this as completed Aug 29, 2013
@mmokrejs
Copy link
Author

No, I did that all. I did not paste here lots of other matches which are either purely python-specific or are still false positivies (although I used the suppression). Shall I post the full version instead? ;-)

@efiring
Copy link
Member

efiring commented Aug 29, 2013

From the FAQ:
"possibly lost" means your program is leaking memory, unless you're doing unusual things with pointers that could cause them to point into the middle of an allocated block; see the user manual for some possible causes. Use --show-possibly-lost=no if you don't want to see these reports.

Given that we are not aware of any demonstrated leaks, my suspicion is that this is a case of "unusual things with pointers". @mdboom can provide more insight.

@mmokrejs
Copy link
Author

I will try to convince you by these my reports elsewhere, which is why I reported just these few and that late in the process of testing. I code only in python, so anything happens to python crashing is either caused by some of numpy/matplotlib/gcc/libc/python or completely other program running and going wild. Provided python developers say they use valgrind regularly and hence that is why they provide the valgrind.supp file ... and provided that these stack traces show matplotlib on the second line from the top ... I think these are matplolib issues.

http://bugs.python.org/issue18843
http://bugs.python.org/issue18845
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58266

@mdboom
Copy link
Member

mdboom commented Aug 29, 2013

We need a few things:

  1. We need to see a self-contained script that reproduces the problem, and ideally we should be able to demonstrate a bonafide leak over time outside of valgrind. Given that the first one is so large, it should be possible to see that in a tool like top without a problem.

  2. The matplotlib compile here is without debug symbols so it's without line numbers. That makes it much harder to tell what allocations these are referring to.

Looking only at the first entry, I'm not convinced this is a bona fide leak. The RendererAgg object is long-lived -- we generally make one of them and keep it around for the lifetime of the process. When Python ends, it may not actually call its destructor (and indeed makes no guarantees that it would). But it only becomes a leak if we get a growing number of these over time, which hasn't been demonstrated.

@mmokrejs
Copy link
Author

I tried to get something liek thsi with some lib/mpl_examples/pylab_examples/ but failed so far.

So, from the top-secret ;-) application triggering that I can give at least:

==13517== 3,763,200 bytes in 1 blocks are possibly lost in loss record 1,913 of 1,913
==13517== at 0x4C2B8F7: operator new[](unsigned long) (vg_replace_malloc.c:363)
==13517== by 0x115525C9: RendererAgg::RendererAgg(unsigned int, unsigned int, double, int) (backend_agg.cpp:408)
==13517== by 0x1155B75D: _backend_agg_module::new_renderer(Py::Tuple const&, Py::Dict const&) (backend_agg.cpp:2413)
==13517== by 0x11582B10: Py::ExtensionModule<_backend_agg_module>::invoke_method_keyword(void*, Py::Tuple const&, Py::Dict const&) (ExtensionModule.hxx:202)
==13517== by 0x115496BE: method_keyword_call_handler (cxx_extensions.cxx:1770)
==13517== by 0x4EEAE33: PyCFunction_Call (methodobject.c:85)
==13517== by 0x4F92ACE: do_call (ceval.c:4236)
==13517== by 0x4F91E25: call_function (ceval.c:4044)
==13517== by 0x4F8C74D: PyEval_EvalFrameEx (ceval.c:2666)
==13517== by 0x4F8F13D: PyEval_EvalCodeEx (ceval.c:3253)
==13517== by 0x4EC6F6E: function_call (funcobject.c:526)
==13517== by 0x4E86908: PyObject_Call (abstract.c:2529)

==13517== 65,536 bytes in 1 blocks are possibly lost in loss record 1,817 of 1,913
==13517== at 0x4C2B8F7: operator new[](unsigned long) (vg_replace_malloc.c:363)
==13517== by 0x11580028: agg::pod_allocatoragg::cell_aa::allocate(unsigned int) (agg_basics.h:38)
==13517== by 0x1157C8B1: agg::rasterizer_cells_aaagg::cell_aa::allocate_block() (agg_rasterizer_cells_aa.h:489)
==13517== by 0x115760C1: agg::rasterizer_cells_aaagg::cell_aa::add_curr_cell() (agg_rasterizer_cells_aa.h:190)
==13517== by 0x1157FD0D: agg::rasterizer_cells_aaagg::cell_aa::set_curr_cell(int, int) (agg_rasterizer_cells_aa.h:203)
==13517== by 0x1157C5DE: agg::rasterizer_cells_aaagg::cell_aa::line(int, int, int, int) (agg_rasterizer_cells_aa.h:398)
==13517== by 0x1157C118: void agg::rasterizer_sl_clipagg::ras_conv_dbl::line_clip_yagg::rasterizer_cells_aa<agg::cell_aa >(agg::rasterizer_cells_aaagg::cell_aa&, double, double, double, double, unsigned int, unsigned int) const (agg_rasterizer_sl_clip.h:157)
==13517== by 0x115759F6: void agg::rasterizer_sl_clipagg::ras_conv_dbl::line_toagg::rasterizer_cells_aa<agg::cell_aa >(agg::rasterizer_cells_aaagg::cell_aa&, double, double) (agg_rasterizer_sl_clip.h:228)
==13517== by 0x115706B2: agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >::line_to_d(double, double) (agg_rasterizer_scanline_aa.h:403)
==13517== by 0x11569C36: agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >::add_vertex(double, double, unsigned int) (agg_rasterizer_scanline_aa.h:420)
==13517== by 0x1156B9FE: void agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >::add_path<agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4> >(agg::conv_curve<PathSimplifier<PathSnapper<
PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4>&, unsigned int) (agg_rasterizer_scanline_aa.h:198)
==13517== by 0x115643D6: void RendererAgg::_draw_path<agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4> >(agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator
, agg::trans_affine> > > > >, agg::curve3, agg::curve4>&, bool, std::pair<bool, agg::rgba> const&, GCAgg const&) (backend_agg.cpp:1170)

==13517== 22,496 bytes in 1 blocks are possibly lost in loss record 1,793 of 1,913
==13517== at 0x4C2C067: operator new(unsigned long) (vg_replace_malloc.c:298)
==13517== by 0x1155B742: _backend_agg_module::new_renderer(Py::Tuple const&, Py::Dict const&) (backend_agg.cpp:2413)
==13517== by 0x11582B10: Py::ExtensionModule<_backend_agg_module>::invoke_method_keyword(void*, Py::Tuple const&, Py::Dict const&) (ExtensionModule.hxx:202)
==13517== by 0x115496BE: method_keyword_call_handler (cxx_extensions.cxx:1770)
==13517== by 0x4EEAE33: PyCFunction_Call (methodobject.c:85)
==13517== by 0x4F92ACE: do_call (ceval.c:4236)
==13517== by 0x4F91E25: call_function (ceval.c:4044)
==13517== by 0x4F8C74D: PyEval_EvalFrameEx (ceval.c:2666)
==13517== by 0x4F8F13D: PyEval_EvalCodeEx (ceval.c:3253)
==13517== by 0x4EC6F6E: function_call (funcobject.c:526)
==13517== by 0x4E86908: PyObject_Call (abstract.c:2529)
==13517== by 0x4EA2B54: instancemethod_call (classobject.c:2602)

==13517== 17,968 bytes in 1 blocks are possibly lost in loss record 1,786 of 1,913
==13517== at 0x4C2B8F7: operator new[](unsigned long) (vg_replace_malloc.c:363)
==13517== by 0x1156890D: agg::pod_allocatoragg::scanline_p8::span::allocate(unsigned int) (agg_basics.h:38)
==13517== by 0x11560832: agg::pod_arrayagg::scanline_p8::span::resize(unsigned int) (agg_array.h:132)
==13517== by 0x1155E076: agg::scanline_p8::reset(int, int) (agg_scanline_p.h:75)
==13517== by 0x1156BC91: void agg::render_scanlinesagg::rasterizer_scanline_aa<agg::rasterizer_sl_clip<agg::ras_conv_dbl >, agg::scanline_p8, agg::renderer_scanline_bin_solid<agg::renderer_base<agg::pixfmt_alpha_blend_rgba<agg::blender_rgba<agg::rgba8, agg::order_rgba>, agg::row_accessor, unsigned
int> > > >(agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >&, agg::scanline_p8&, agg::renderer_scanline_bin_solid<agg::renderer_base<agg::pixfmt_alpha_blend_rgba<agg::blender_rgba<agg::rgba8, agg::order_rgba>, agg::row_accessor, unsigned int> > >&) (agg_renderer_scanline.h:442)
==13517== by 0x11564697: void RendererAgg::_draw_path<agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4> >(agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator
, agg::trans_affine> > > > >, agg::curve3, agg::curve4>&, bool, std::pair<bool, agg::rgba> const&, GCAgg const&) (backend_agg.cpp:1201)
==13517== by 0x11556B23: RendererAgg::draw_path(Py::Tuple const&) (backend_agg.cpp:1379)
==13517== by 0x1156FBAF: Py::PythonExtension::method_varargs_call_handler(object, object) (ExtensionOldType.hxx:302)
==13517== by 0x4EEAE15: PyCFunction_Call (methodobject.c:81)
==13517== by 0x4F91C08: call_function (ceval.c:4021)
==13517== by 0x4F8C74D: PyEval_EvalFrameEx (ceval.c:2666)
==13517== by 0x4F8F13D: PyEval_EvalCodeEx (ceval.c:3253)

==13517== 13,568 bytes in 1 blocks are possibly lost in loss record 1,778 of 1,913
==13517== at 0x4C2B8F7: operator new[](unsigned long) (vg_replace_malloc.c:363)
==13517== by 0x1158000C: agg::pod_allocatoragg::cell_aa*::allocate(unsigned int) (agg_basics.h:38)
==13517== by 0x1157C95E: agg::pod_vectoragg::cell_aa*::capacity(unsigned int, unsigned int) (agg_array.h:227)
==13517== by 0x11576161: agg::pod_vectoragg::cell_aa*::allocate(unsigned int, unsigned int) (agg_array.h:235)
==13517== by 0x1157079F: agg::rasterizer_cells_aaagg::cell_aa::sort_cells() (agg_rasterizer_cells_aa.h:651)
==13517== by 0x11569C88: agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >::rewind_scanlines() (agg_rasterizer_scanline_aa.h:467)
==13517== by 0x1156BC61: void agg::render_scanlinesagg::rasterizer_scanline_aa<agg::rasterizer_sl_clip<agg::ras_conv_dbl >, agg::scanline_p8, agg::renderer_scanline_bin_solid<agg::renderer_base<agg::pixfmt_alpha_blend_rgba<agg::blender_rgba<agg::rgba8, agg::order_rgba>, agg::row_accessor, unsigned
int> > > >(agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >&, agg::scanline_p8&, agg::renderer_scanline_bin_solid<agg::renderer_base<agg::pixfmt_alpha_blend_rgba<agg::blender_rgba<agg::rgba8, agg::order_rgba>, agg::row_accessor, unsigned int> > >&) (agg_renderer_scanline.h:440)
==13517== by 0x11564697: void RendererAgg::_draw_path<agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4> >(agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator
, agg::trans_affine> > > > >, agg::curve3, agg::curve4>&, bool, std::pair<bool, agg::rgba> const&, GCAgg const&) (backend_agg.cpp:1201)
==13517== by 0x11556B23: RendererAgg::draw_path(Py::Tuple const&) (backend_agg.cpp:1379)
==13517== by 0x1156FBAF: Py::PythonExtension::method_varargs_call_handler(object, object) (ExtensionOldType.hxx:302)
==13517== by 0x4EEAE15: PyCFunction_Call (methodobject.c:81)
==13517== by 0x4F91C08: call_function (ceval.c:4021)

==13517== 6,856 bytes in 1 blocks are possibly lost in loss record 1,735 of 1,913
==13517== at 0x4C2B8F7: operator new[](unsigned long) (vg_replace_malloc.c:363)
==13517== by 0x11580044: agg::pod_allocatoragg::rasterizer_cells_aaagg::cell_aa::sorted_y::allocate(unsigned int) (agg_basics.h:38)
==13517== by 0x1157C9D8: agg::pod_vectoragg::rasterizer_cells_aaagg::cell_aa::sorted_y::capacity(unsigned int, unsigned int) (agg_array.h:227)
==13517== by 0x11576193: agg::pod_vectoragg::rasterizer_cells_aaagg::cell_aa::sorted_y::allocate(unsigned int, unsigned int) (agg_array.h:235)
==13517== by 0x115707CD: agg::rasterizer_cells_aaagg::cell_aa::sort_cells() (agg_rasterizer_cells_aa.h:654)
==13517== by 0x11569C88: agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >::rewind_scanlines() (agg_rasterizer_scanline_aa.h:467)
==13517== by 0x1156BC61: void agg::render_scanlinesagg::rasterizer_scanline_aa<agg::rasterizer_sl_clip<agg::ras_conv_dbl >, agg::scanline_p8, agg::renderer_scanline_bin_solid<agg::renderer_base<agg::pixfmt_alpha_blend_rgba<agg::blender_rgba<agg::rgba8, agg::order_rgba>, agg::row_accessor, unsigned int> > > >(agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >&, agg::scanline_p8&, agg::renderer_scanline_bin_solid<agg::renderer_base<agg::pixfmt_alpha_blend_rgba<agg::blender_rgba<agg::rgba8, agg::order_rgba>, agg::row_accessor, unsigned int> > >&) (agg_renderer_scanline.h:440)
==13517== by 0x11564697: void RendererAgg::_draw_path<agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4> >(agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4>&, bool, std::pair<bool, agg::rgba> const&, GCAgg const&) (backend_agg.cpp:1201)
==13517== by 0x11556B23: RendererAgg::draw_path(Py::Tuple const&) (backend_agg.cpp:1379)
==13517== by 0x1156FBAF: Py::PythonExtension::method_varargs_call_handler(object, object) (ExtensionOldType.hxx:302)
==13517== by 0x4EEAE15: PyCFunction_Call (methodobject.c:81)
==13517== by 0x4F91C08: call_function (ceval.c:4021)

==13517== 2,048 bytes in 1 blocks are possibly lost in loss record 1,631 of 1,913
==13517== at 0x4C2B8F7: operator new[](unsigned long) (vg_replace_malloc.c:363)
==13517== by 0x1158000C: agg::pod_allocatoragg::cell_aa*::allocate(unsigned int) (agg_basics.h:38)
==13517== by 0x1157C81D: agg::rasterizer_cells_aaagg::cell_aa::allocate_block() (agg_rasterizer_cells_aa.h:478)
==13517== by 0x115760C1: agg::rasterizer_cells_aaagg::cell_aa::add_curr_cell() (agg_rasterizer_cells_aa.h:190)
==13517== by 0x1157FD0D: agg::rasterizer_cells_aaagg::cell_aa::set_curr_cell(int, int) (agg_rasterizer_cells_aa.h:203)
==13517== by 0x1157C5DE: agg::rasterizer_cells_aaagg::cell_aa::line(int, int, int, int) (agg_rasterizer_cells_aa.h:398)
==13517== by 0x1157C118: void agg::rasterizer_sl_clipagg::ras_conv_dbl::line_clip_yagg::rasterizer_cells_aa<agg::cell_aa >(agg::rasterizer_cells_aaagg::cell_aa&, double, double, double, double, unsigned int, unsigned int) const (agg_rasterizer_sl_clip.h:157)
==13517== by 0x115759F6: void agg::rasterizer_sl_clipagg::ras_conv_dbl::line_toagg::rasterizer_cells_aa<agg::cell_aa >(agg::rasterizer_cells_aaagg::cell_aa&, double, double) (agg_rasterizer_sl_clip.h:228)
==13517== by 0x115706B2: agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >::line_to_d(double, double) (agg_rasterizer_scanline_aa.h:403)
==13517== by 0x11569C36: agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >::add_vertex(double, double, unsigned int) (agg_rasterizer_scanline_aa.h:420)
==13517== by 0x1156B9FE: void agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >::add_path<agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4> >(agg::conv_curve<PathSimplifier<PathSnapper<
PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4>&, unsigned int) (agg_rasterizer_scanline_aa.h:198)
==13517== by 0x115643D6: void RendererAgg::_draw_path<agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4> >(agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator
, agg::trans_affine> > > > >, agg::curve3, agg::curve4>&, bool, std::pair<bool, agg::rgba> const&, GCAgg const&) (backend_agg.cpp:1170)

==13517== 1,123 bytes in 1 blocks are possibly lost in loss record 1,560 of 1,913
==13517== at 0x4C2B8F7: operator new[](unsigned long) (vg_replace_malloc.c:363)
==13517== by 0x11560224: agg::pod_allocator::allocate(unsigned int) (agg_basics.h:38)
==13517== by 0x1156072C: agg::pod_array::resize(unsigned int) (agg_array.h:132)
==13517== by 0x1155E08B: agg::scanline_p8::reset(int, int) (agg_scanline_p.h:76)
==13517== by 0x1156BC91: void agg::render_scanlinesagg::rasterizer_scanline_aa<agg::rasterizer_sl_clip<agg::ras_conv_dbl >, agg::scanline_p8, agg::renderer_scanline_bin_solid<agg::renderer_base<agg::pixfmt_alpha_blend_rgba<agg::blender_rgba<agg::rgba8, agg::order_rgba>, agg::row_accessor, unsigned int> > > >(agg::rasterizer_scanline_aaagg::rasterizer_sl_clip<agg::ras_conv_dbl >&, agg::scanline_p8&, agg::renderer_scanline_bin_solid<agg::renderer_base<agg::pixfmt_alpha_blend_rgba<agg::blender_rgba<agg::rgba8, agg::order_rgba>, agg::row_accessor, unsigned int> > >&) (agg_renderer_scanline.h:442)
==13517== by 0x11564697: void RendererAgg::_draw_path<agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4> >(agg::conv_curve<PathSimplifier<PathSnapper<PathClipper<PathNanRemover<agg::conv_transform<PathIterator, agg::trans_affine> > > > >, agg::curve3, agg::curve4>&, bool, std::pair<bool, agg::rgba> const&, GCAgg const&) (backend_agg.cpp:1201)
==13517== by 0x11556B23: RendererAgg::draw_path(Py::Tuple const&) (backend_agg.cpp:1379)
==13517== by 0x1156FBAF: Py::PythonExtension::method_varargs_call_handler(object, object) (ExtensionOldType.hxx:302)
==13517== by 0x4EEAE15: PyCFunction_Call (methodobject.c:81)
==13517== by 0x4F91C08: call_function (ceval.c:4021)
==13517== by 0x4F8C74D: PyEval_EvalFrameEx (ceval.c:2666)
==13517== by 0x4F8F13D: PyEval_EvalCodeEx (ceval.c:3253)

==13517== 48 bytes in 1 blocks are possibly lost in loss record 789 of 1,913
==13517== at 0x4C2C067: operator new(unsigned long) (vg_replace_malloc.c:298)
==13517== by 0xF74B84C: Py::ExtensionModuleBase::initialize(char const_) (cxx_extensions.cxx:224)
==13517== by 0xF748830: Py::ExtensionModule<png_module>::initialize(char const) (ExtensionModule.hxx:125)
==13517== by 0xF748496: _png_module::_png_module() (_png.cpp:54)
==13517== by 0xF7474B0: init_png (png.cpp:625)
==13517== by 0x4FB47DD: PyImport_LoadDynamicModule (importdl.c:53)
==13517== by 0x4FB0559: load_module (import.c:1915)
==13517== by 0x4FB2973: import_submodule (import.c:2700)
==13517== by 0x4FB1E78: load_next (import.c:2515)
==13517== by 0x4FB0FA4: import_module_level (import.c:2232)
==13517== by 0x4FB14D2: PyImport_ImportModuleLevel (import.c:2288)
==13517== by 0x4F7A912: builtin___import
(bltinmodule.c:49)

That's all I could do. Either it helps, or not.

@mdboom
Copy link
Member

mdboom commented Aug 29, 2013

Sorry, I can't help you if you aren't willing to share what is reproducing the problem. It doesn't have to be exactly your code if you don't want to share it, but we do need a simple, self-contained example. Otherwise, this is just guesswork. You may be interested in reading this: http://sscce.org/

@mmokrejs
Copy link
Author

It is not a question of will but of time. I spent 2 days on the memory issues and not have to recompile back to normal state (--without-pydebug). Maybe later.

@mmokrejs
Copy link
Author

So I am still stuck with memory corruption issues and was sent by python devs back to you with this stracktrace. It will not help with my issues but you may want to know about that:

==17489== 40 bytes in 1 blocks are definitely lost in loss record 718 of 5,487
==17489== at 0x4C2C63B: malloc (vg_replace_malloc.c:270)
==17489== by 0x4EF1E8C: PyMem_Malloc (object.c:2343)
==17489== by 0x10064848: initialize_builtin_datetime_metadata (arraytypes.c.src:3953)
==17489== by 0x100719E2: set_typeinfo (arraytypes.c.src:4047)
==17489== by 0x1016354E: initmultiarray (multiarraymodule.c:4057)
==17489== by 0x4FB2661: PyImport_LoadDynamicModule (importdl.c:53)
==17489== by 0x4FAE3A7: load_module (import.c:1915)
==17489== by 0x4FB07C1: import_submodule (import.c:2700)
==17489== by 0x4FAFCC6: load_next (import.c:2515)
==17489== by 0x4FAED8B: import_module_level (import.c:2224)
==17489== by 0x4FAF320: PyImport_ImportModuleLevel (import.c:2288)
==17489== by 0x4F78862: builtin___import
_ (bltinmodule.c:49)

Initially it appeared that happens if I recompile python to provide debug ABI (which in turn means one must recompile all python-based apps) and import not-yet-recompiled module. In this case it was matplotlib which failed on import. But later I got this again and there was no import error. No, no testcase, at least yet.

http://bugs.python.org/issue18884

@WeatherGod
Copy link
Member

Actually, based on this, the errors are with NumPy, not matplotlib. None of
the modules mentioned here are matplotlib modules.

On Fri, Aug 30, 2013 at 3:55 PM, mmokrejs notifications@github.com wrote:

So I am still stuck with memory corruption issues and was sent by python
devs back to you with this stracktrace. It will not help with my issues but
you may want to know about that:

==17489== 40 bytes in 1 blocks are definitely lost in loss record 718 of
5,487
==17489== at 0x4C2C63B: malloc (vg_replace_malloc.c:270)
==17489== by 0x4EF1E8C: PyMem_Malloc (object.c:2343)
==17489== by 0x10064848: initialize_builtin_datetime_metadata
(arraytypes.c.src:3953)
==17489== by 0x100719E2: set_typeinfo (arraytypes.c.src:4047)
==17489== by 0x1016354E: initmultiarray (multiarraymodule.c:4057)
==17489== by 0x4FB2661: PyImport_LoadDynamicModule (importdl.c:53)
==17489== by 0x4FAE3A7: load_module (import.c:1915)
==17489== by 0x4FB07C1: import_submodule (import.c:2700)
==17489== by 0x4FAFCC6: load_next (import.c:2515)
==17489== by 0x4FAED8B: import_module_level (import.c:2224)
==17489== by 0x4FAF320: PyImport_ImportModuleLevel (import.c:2288)
==17489== by 0x4F78862: builtin
import (bltinmodule.c:49)

Initially it appeared that happens if I recompile python to provide debug
ABI (which in turn means one must recompile all python-based apps) and
import not-yet-recompiled module. In this case it was matplotlib which
failed on import. But later I got this again and there was no import error.
No, no testcase, at least yet.

http://bugs.python.org/issue18884


Reply to this email directly or view it on GitHubhttps://github.com//issues/2354#issuecomment-23585488
.

@mdboom
Copy link
Member

mdboom commented Aug 30, 2013

Besides, that is very unlikely a real memory leak. It happens inside the initmultiarray function. Python extensions (at least on Python 2.x) don't have destructors, so the objects the allocate in their init are never freed (which in practice is a non-issue, since you can't unload a module in Python anyway).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants