[cairo] Underflowing reference counts

Steve Chaplin stevech1097 at yahoo.com.au
Thu Apr 7 10:26:49 PDT 2005


I noticed a couple of problems with the PS backend

1) cairo_surface_destroy() calls
   ps_surface_finish() which calls
   cairo_surface_destroy()

and you can end up with sequence like this:
cairo_surface_destroy start, ref_count=1
cairo_surface_destroy end, ref_count=0
cairo_surface_destroy start, ref_count=1
cairo_surface_destroy end, ref_count=0
cairo_surface_destroy start, ref_count=2
cairo_surface_destroy end, ref_count=1
cairo_surface_destroy start, ref_count=1
ps_surface_finish start
cairo_surface_destroy start, ref_count=1
cairo_surface_destroy end, ref_count=6940744
ps_surface_finish end
cairo_surface_destroy end, ref_count=6940744


2) cairo_surface_finish () has the lines:
    if (surface->finished)
	return CAIRO_STATUS_SURFACE_FINISHED;

    if (surface->backend->finish)
	return surface->backend->finish (surface);

I can't see surface->finished being set to TRUE anywhere,
so that clause is never used and surface->backend->finish (surface)
can be invoked multiple times.

For the PS backend I got this sequence
cairo_surface_destroy start, ref_count=1
cairo_surface_destroy end, ref_count=0
cairo_surface_destroy start, ref_count=1
cairo_surface_destroy end, ref_count=0
ps_surface_finish start
cairo_surface_destroy start, ref_count=1
cairo_surface_destroy end, ref_count=6940744
ps_surface_finish end
cairo_surface_destroy start, ref_count=2
cairo_surface_destroy end, ref_count=1
cairo_surface_destroy start, ref_count=1
ps_surface_finish start
cairo_surface_destroy start, ref_count=143589376
cairo_surface_destroy end, ref_count=143589375
ps_surface_finish end
cairo_surface_destroy end, ref_count=6940744

Attached is the program I was using (with print statements also added 
to the cairo src)

Steve


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ps_test.c
Type: text/x-csrc
Size: 973 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050408/49785c95/ps_test.c


More information about the cairo mailing list