Bug 91396 - Memory leak in cairo-script-surface
Summary: Memory leak in cairo-script-surface
Status: RESOLVED MOVED
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Chris Wilson
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-19 14:38 UTC by Massimo
Modified: 2018-08-25 13:39 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
plug a memory leak (2.52 KB, text/plain)
2015-07-19 14:38 UTC, Massimo
Details
script: Plug a memory leak using recording surfaces and vector glyph (4.55 KB, patch)
2015-07-19 15:08 UTC, Chris Wilson
Details | Splinter Review

Description Massimo 2015-07-19 14:38:00 UTC
Created attachment 117248 [details]
plug a memory leak

The bug is that in '_emit_recording_surface_pattern' the current cr is
saved on the stack in 'old_cr':

http://cgit.freedesktop.org/cairo/tree/src/cairo-script-surface.c#n1173

if replaying the recording surface 'emit_source' is called it is possible
that the 'current_source' member of surface->cr is finished and in its
place is copied the new source, (for surface_patterns this means that the new
source surface ref count is incremented):

http://cgit.freedesktop.org/cairo/tree/src/cairo-script-surface.c#n1741
    
but exiting the recursion 'old_cr' is assigned/raw-copied onto surface->cr and
current_source is overwritten without the matching ref count decrement.
    
compiling cairo with -fsanitize=address Gcc option and running

(cd test; CAIRO_TEST_TARGET=recording ./cairo-test-suite -f user-font-mask )

the report ends with:
... 
SUMMARY: AddressSanitizer: 7632 byte(s) leaked in 27 allocation(s).
Comment 1 Chris Wilson 2015-07-19 15:08:03 UTC
Created attachment 117249 [details] [review]
script: Plug a memory leak using recording surfaces and vector glyph

Hah, I wrote an almost identical patch!
Comment 2 GitLab Migration User 2018-08-25 13:39:54 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/124.


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.