[cairo] For libsvg-cairo, glibc-detected corrupted double-linked list detected.

Jason Dorje Short jdorje at users.sf.net
Mon Jul 25 18:56:49 PDT 2005

charles wrote:
> Hi:
> When I do some transformation before call svg_cairo_render, and error
> '*** glibc detected *** corrupted double-linked list: 0x08eea120 ***' is
> encountered. (If I no transformation is applied, this error is not
> occurred.).

Is that supposed to be caused by this test program?  I don't see it.
The only errors valgrind gives are uninitialized-data ones.  This error
sounds like memory corruption overwriting some glib data (an "invalid
write" in valgrind).

> My test program is very simple, so I think it might be caused by
> 'libsvg-cairo'. (Forgive me if it is my fault).

One problem I notice is that cairo_image_surface_get_width has no checks
on its input.  So code like the following:

    mmsr = cairo_image_surface_create_from_png("mm.png");
    mmw = cairo_image_surface_get_width(mmsr);
    mmh = cairo_image_surface_get_height(mmsr);

will simply crash if mm.png is not present.  I guess this might be
intentional but it does make debugging harder.

Aside from this I think the problem is you never initialize (clear) the
surface.  Thus pixels that aren't drawn to by any other operation end up
with unitialized data.

    cairo_save (cr);
    cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
    cairo_paint (cr);
    cairo_restore (cr);

Maybe image surfaces should be created "cleared" (all zeroed - either
transparent or black depending on surface format).

Also you call cairo_destroy(cr) twice.

Finally I suggest using --num-callers=50 with valgrind (50 is the
maximum).  Valgrind's default of 4 callers is often not useful.


More information about the cairo mailing list