Project

General

Profile

Actions

Bug #3639

closed

Two memory leaks in Render with internal stylesheets

Added by Bruce Toll about 10 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
10/28/2014
Due date:
% Done:

0%

Estimated time:

Description

It looks like there are a couple of memory leaks with internal stylesheets in Render with the github 3.3.3-21-g7a82136 version of Wt. To reproduce, the attached patch includes a modified version of the raster_test_textRenderer that can be run under valgrind. Since the valgrind output is noisy without a suppression file (due to some of the graphics libraries), I've also attached a valgrind suppression file, valgrind_graphics.supp, that streamlines the output (at least on my Debian Wheezy system) if the num-callers option is raised to 20. The full valgrind command used was:

valgrind --suppressions=valgrind_graphics.supp --leak-check=full --num-callers=20 --log-file=valgrind_%p.log ./test -t 'raster_test_text_embedded_stylesheet'

The valgrind output (lightly edited to show relevant portion):

Memcheck, a memory error detector
Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
Command: ./test -t raster_test_text_embedded_stylesheet


HEAP SUMMARY:
    in use at exit: 340,347 bytes in 3,031 blocks
  total heap usage: 12,477 allocs, 9,446 frees, 3,361,608 bytes allocated

612 (32 direct, 580 indirect) bytes in 1 blocks are definitely lost in loss record 764 of 877
   at: operator new(unsigned long) (vg_replace_malloc.c:287)
   by: Wt::Render::CssParser::parse(Wt::WString const&) (CssParser.C:448)
   by: Wt::Render::WTextRenderer::render(Wt::WString const&, double) (WTextRenderer.C:190)
   by: raster_test_text_embedded_stylesheet::test_method() (WRasterTest.C:108)
   by: raster_test_text_embedded_stylesheet_invoker() (WRasterTest.C:91)

704 (344 direct, 360 indirect) bytes in 1 blocks are definitely lost in loss record 772 of 877
   at: operator new(unsigned long) (vg_replace_malloc.c:287)
   by: Wt::Render::Utils::fetchBlockChildren(Wt::rapidxml::xml_node<char>*, Wt::Render::Block*,
           std::vector<Wt::Render::Block*, std::allocator<Wt::Render::Block*> >&) (RenderUtils.C:68)
   by: Wt::Render::Block::Block(Wt::rapidxml::xml_node<char>*, Wt::Render::Block*) (Block.C:90)
   by: Wt::Render::WTextRenderer::render(Wt::WString const&, double) (WTextRenderer.C:179)
   by: raster_test_text_embedded_stylesheet::test_method() (WRasterTest.C:108)
   by: raster_test_text_embedded_stylesheet_invoker() (WRasterTest.C:91)

LEAK SUMMARY:
   definitely lost: 376 bytes in 2 blocks
   indirectly lost: 9,260 bytes in 270 blocks
     possibly lost: 0 bytes in 0 blocks
   still reachable: 3,156 bytes in 22 blocks
        suppressed: 327,555 bytes in 2,737 blocks
Reachable blocks (those to which a pointer was found) are not shown.
To see them, rerun with: --leak-check=full --show-reachable=yes

For counts of detected and suppressed errors, rerun with: -v
ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 275 from 265)

The attached patch also includes minor modifications to Block.C and WTextRenderer.C that seem to help with the issue. But, it's only had limited testing and could definitely benefit from review.


Files

Actions #1

Updated by Koen Deforche almost 10 years ago

  • Status changed from New to Resolved
  • Assignee set to Koen Deforche
  • Target version set to 3.3.4

Hey Bruce,

I believe you're right and with a relatively big test suite of html, this patch does not create any problems. But I believe some code review from our side is in order since simple ownership principles seem not to apply to it.

Koen

Actions #2

Updated by Koen Deforche over 9 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF