[cairo] Fix crash - SurfacePatternDrawFunc in cairo-quartz-surface.c

Mox Soini mox at iki.fi
Tue Apr 10 23:38:01 PDT 2007

Hi again,

Brian, your guesses were correct.
1) Quartz Cairo backend does not support native snapshot, so fallback is used
2) Fallback eventually boils down to _cairo_quartz_get_image

In my case, that function was failing, because the OOo code did not
have the proper kCGBitmapByteOrder32Host set, and thus the _get_image

After fixing that on the OOo side, the cairo code worked fine. So this
bug helped to fix some OOo code, nice.

However, I'm not sure it is good behaviour to allow the code to crash
on a semi-random place. If we are at the moment interested in
improving the unimplemented areas, then maybe an assert, with code
comment would be good there...

How about this fix in the attached patch?


On 4/6/07, Baz <brian.ewins at gmail.com> wrote:
> On 06/04/07, Mox Soini <mox at iki.fi> wrote:
> > Otherwise it seems to be working fine, except when the code was
> > implemented in OOo to take advantage of native images as source
> > surface (using CGBitmapContext), the SurfacePatternDrawFunc() crashed.
> >
> > This was caused by _init_pattern_with_snapshot() failing in
> > _cairo_quartz_cairo_repeating_surface_pattern_to_quartz()
> The last bit of the patch, where the you fallback from the snapshot
> error, doesnt seem quite right. It'd be good to have a testcase that
> reproduces your crash so we can see what's actually going wrong there?
> At a guess the original error is going to be happening something like
> this:
> _init_pattern_with_snapshot ->
> _cairo_surface_snapshot ->
> _cairo_surface_fallback_snapshot ->
> _cairo_surface_acquire_source_image ->
> _cairo_quartz_surface_acquire_source_image ->
> _cairo_quartz_get_image
> ... and then hits one of the 'unsupported' image types. If that is
> what's caused the problem, I'm curious how we managed to get an
> incompatible image type in the pattern, and whether we could fix that
> underlying problem instead. (similar problems with xlib are on the
> roadmap).
> Cheers,
> Baz

Mox on G
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo-quartz-repeatingpattern-crashfix2.patch
Type: application/octet-stream
Size: 1456 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20070411/e0997f6b/cairo-quartz-repeatingpattern-crashfix2-0001.obj

More information about the cairo mailing list