[cairo] User code triggers some inner Cairo assert

Sebastien Kramm sebastien.kramm at univ-rouen.fr
Sat Sep 15 05:02:44 PDT 2012

On 09/14/2012 06:17 PM, Jonas Kulla wrote:
> 2012/9/14 Sebastien Kramm <sebastien.kramm at univ-rouen.fr
> <mailto:sebastien.kramm at univ-rouen.fr>>
>     Hello,
>     This is my first post here.
>     For some application, I am writing a wrapper over basic drawing stuff with cairo,
>     and the corresponding images are displayed into Gtk+2 windows. It ""kinda
>     works"". However, one of my samples triggers an internal cairo assert, and I
>     really don't see how to fix this. The log is:
>     demo1: /build/buildd/cairo-1.10.2/__src/cairo.c:173: _cairo_error: Assertion
>     `(status != CAIRO_STATUS_SUCCESS && status <= CAIRO_STATUS_LAST_STATUS)' failed.
>     Something in my code is probably doing something really bad, but I don't know what.
>     FIY, its a C++ app, that is calling a set of C functions that are wrappers over
>     the drawing back-end library (Cairo) and window managment (Gtk+2).
>     I only use a small subset of the Cairo functions, drawing on images is done with
>     the classical pattern (creating a cairo_t* with cairo_create(), drawing, then
>     release the object).
>      >From error message, I seem to be using 1.10 version (plateform is Ubuntu
>     12.04). I tried to upgrade to 1.12, but the classical:
>        sudo apt-get install libcairo2-dev
>     as suggested by:
>     http://www.cairographics.org/__download/ <http://www.cairographics.org/download/>
>     tells me that:
>        "libcairo2-dev is already the newest version"
>     (although this seems to be false).
>     I checked the corresponding code via:
>     http://cgit.freedesktop.org/__cairo/tree/src/cairo.c?id=1.__10.2
>     <http://cgit.freedesktop.org/cairo/tree/src/cairo.c?id=1.10.2>
>     and the assert is in some function:
>         cairo_status_t _cairo_error (cairo_status_t status)
>     that my code does NOT call.
>     My knowledge of Cairo is very limited, so I'm stuck. Any advice on how to move on
>     would be appreciated.
> Hi Sebastien,
> it would really really help if you could provide some source code, or at the very least
> the part of your code which triggers the assert.
> You most likely called a function on your surface which failed and set the suface
> status to "error", but didn't detect this and attempted to call another function on
> said surface.
> Mind you, my knowledge of cairo is very limited, so that is just an assumption.

Hi Jonas,
Thank you for your answer.
I also suspected something like this, I carefully read the "error handling" page on 
Cairo, and added correct error handling on all of my cairo_surface_t pointers, like this:
if(  cairo_surface_status( im ) !=  CAIRO_STATUS_SUCCESS )
   cerr << __FUNCTION__ << ": cairo error: "
        << cairo_status_to_string ( cairo_surface_status( im ) ) << endl;

At the end, I end up with a crash without any warning as above, and this only in 
release mode, but not in debug mode (GCC likes to keep things fun...)
So probably not related to Cairo, but to some kind of memory corruption, I'm 
currently into Valgrind to track that down.

I'll let you now if I find something cairo-related.


More information about the cairo mailing list