[Mono-dev] SIGSEGV in Cairo.CairoAPI:cairo_get/set_matrix()

Idan Gazit idan at fastmail.fm
Mon Oct 31 19:52:17 EST 2005

Hi again,

John Luke wrote:
> Hey,
> I think ref is used in too many places.  Perhaps I am wrong, but at
> least for the set_* methods they won't be modifying it.

Regarding set_*: True. I think the api calls break down into two groups:
those that read (ref) and those that create a new matrix to fill the
reference with (out). I can't think of any calls where I pass in a ref
Matrix and expect cairo to modify my matrix, but it is 2:30 and my brain
is foggy.

> Maybe going through the cairo docs can help you decide to use
> out/ref/neither for each of those calls, if you didn't already.
> For example, cairo_get_matrix looks like it should be out, and
> cairo_set_matrix looks like it should not be ref or out.

Regarding use of ref/out/neither: I think use of ref or out is
*required*. It seems that (most) cairo calls involving matrices expect a
cairo_matrix_t* argument. As I understand it, this means that these
calls require EITHER ref OR out, depending on whether or not I expect
cairo to do the malloc()ing for me. I don't see any case where "neither"
ref nor out is appropriate -- cairo-the-c-lib expects a pointer, not the
struct. The segfault I experienced which started this whole thing was
because a Matrix_T and not a ref Matrix_T was passed...

Empirical tests show that I segfault whenever I try passing a Matrix_T
to cairo (and not a ref Matrix_T). Perhaps I am misunderstanding?
Anybody please jump in to set my head straight.

> For the Matrix struct, the public fields should have the first letter
> capitalized.

Done. I'll reissue a new patch when I'm done testing.

> The rest looks sane, but I haven't tested it.  Do any of the samples use
> these parts? and if so do they work with these changes?
> Hope that helps.

I haven't tried it yet on the samples, but in testing my own apps work
with it hunky-dory. :)

Basically the changes to Matrix constitute api breakage, which is pretty
unavoidable. :( Apps which to date didn't use matrices directly should
be immune, as Cairo.Graphics shields them from it.

I'll go through the samples and test, and issue a patch for those as
well if they break.


More information about the Mono-devel-list mailing list