[cairo-bugs] [Bug 56981] New: regression in cairo_surface_t refcounting when using cairo_surface_unmap_image

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Sun Nov 11 06:51:39 PST 2012


https://bugs.freedesktop.org/show_bug.cgi?id=56981

          Priority: medium
            Bug ID: 56981
          Assignee: chris at chris-wilson.co.uk
           Summary: regression in cairo_surface_t refcounting when using
                    cairo_surface_unmap_image
        QA Contact: cairo-bugs at cairographics.org
          Severity: normal
    Classification: Unclassified
                OS: Linux (All)
          Reporter: richard at hughsie.com
          Hardware: Other
            Status: NEW
           Version: 1.12.8
         Component: general
           Product: cairo

Using cairo 1.12.2 this code returns correctly with no warnings or errors:

//gcc -o cairo-test2 cairo-test2.c `pkg-config --cflags --libs cairo-pdf` &&
./cairo-test2
#include <glib.h>
#include <cairo.h>
int
main (int argc, char *argv[])
{
    cairo_surface_t *surface;
    cairo_surface_t *s2;
    surface = cairo_pdf_surface_create ("/tmp/dave.pdf", 300, 300);
    s2 = cairo_surface_map_to_image (surface, NULL);
    cairo_surface_unmap_image (surface, s2);
    cairo_surface_destroy (surface);
    return 0;
}

When testing with the more recent 1.12.8 I get:

cairo-test2: cairo-surface.c:930: cairo_surface_destroy: Assertion
`((*&(&surface->ref_count)->ref_count) > 0)' failed.

This can be worked around by doing something like this:

    cairo_surface_reference (surface); // <--- THIS SHOULD NOT BE REQUIRED!!!
    cairo_surface_unmap_image (surface, s2);

The documentation says: "The content of the image will be uploaded to the
target surface. Afterwards, the image is destroyed." It doesn't say anything
about unreffing the parent surface and this is quite unexpected.

Any help welcome, thanks.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo-bugs/attachments/20121111/d21312d7/attachment.html>


More information about the cairo-bugs mailing list