Bug 91267

Summary: memory leak
Product: cairo Reporter: Massimo <sixtysix>
Component: xcb backendAssignee: Uli Schlachter <psychon>
Status: RESOLVED MOVED QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Massimo 2015-07-08 11:48:12 UTC
Running:

( cd test; DISPLAY=:2 CAIRO_TEST_TARGET=xcb valgrind --leak-check=full .libs/cairo-test-suite -f random-clip )

valgrind reports:

 ==475== 6,160 (144 direct, 6,016 indirect) bytes in 2 blocks are definitely lost in loss record 10 of 10
==475==    at 0x4A06C10: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==475==    by 0x4C353FA: _cairo_clip_create (cairo/src/cairo-clip.c:111)
==475==    by 0x4C35649: _cairo_clip_copy (cairo/src/cairo-clip.c:151)
==475==    by 0x4C36F73: _cairo_clip_copy_intersect_rectangle (cairo/src/cairo-clip-inline.h:58)
==475==    by 0x4C36F73: _cairo_clip_reduce_to_rectangle (cairo/src/cairo-clip-boxes.c:559)
==475==    by 0x4C381E2: _cairo_composite_rectangles_intersect_mask_extents (cairo/src/cairo-composite-rectangles.c:292)
==475==    by 0x4CBB06A: trim_extents_to_traps (cairo/src/cairo-xcb-surface-render.c:2859)
==475==    by 0x4CBB06A: _composite_polygon (cairo/src/cairo-xcb-surface-render.c:3065)
==475==    by 0x4CBA529: _clip_and_composite_boxes (cairo/src/cairo-xcb-surface-render.c:3141)
==475==    by 0x4CBC5ED: _cairo_xcb_render_compositor_paint (cairo/src/cairo-xcb-surface-render.c:3556)
==475==    by 0x4C38CE8: _cairo_compositor_paint (cairo/src/cairo-compositor.c:65)
==475==    by 0x4C7EB40: _cairo_surface_paint (cairo/src/cairo-surface.c:2117)
==475==    by 0x4C4062E: _cairo_gstate_paint (cairo/src/cairo-gstate.c:1067)
==475==    by 0x4C33BC4: cairo_paint (cairo/src/cairo.c:2003)
==475==    by 0x439B3C: draw (cairo/test/random-clips.c:221)
==475==    by 0x40E5F1: cairo_test_for_target (cairo/test/cairo-test.c:929)
==475==    by 0x40E5F1: _cairo_test_context_run_for_target (cairo/test/cairo-test.c:1532)
==475==    by 0x40BA53: _cairo_test_runner_draw (cairo/test/cairo-test-runner.c:255)
==475==    by 0x40BA53: main (cairo/test/cairo-test-runner.c:937)

In '_clip_and_composite_boxes':

http://cgit.freedesktop.org/cairo/tree/src/cairo-xcb-surface-render.c#n3140

A copy (intersected with 'boxes') of extents->clip is assigned to 
extents->clip which is passed to '_composite_polygon', when
'_composite_polygon' changes again extents->clip, it destroys the previous
copy and places there a new one (simplified or whatever), this new one
is leaked because at line 3147 rather then assign it to 'clip' which
will be destroyed few lines later, NULL is assigned to 'clip' and the next
line extents->clip is overwritten with the original.

My suggestion here is to assign extents->clip to 'clip' at line 3147.
Comment 1 GitLab Migration User 2018-08-25 13:28:57 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/cairo/cairo/issues/24.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.