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

Baz brian.ewins at gmail.com
Wed Apr 11 02:50:02 PDT 2007


On 11/04/07, Mox Soini <mox at iki.fi> wrote:
> 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
> failed.
>
> After fixing that on the OOo side, the cairo code worked fine. So this
> bug helped to fix some OOo code, nice.

cool!

>
> 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...

I agree that the code should not be crashing in random places :). I'm
happier with this form of the patch, especially now you've identified
that bad input triggering the crash. However I'm not going to be able
to touch this today, and the release is imminent - Vlad, if you want
this behaviour in 1.4.4 can you take a quick look?

Otherwise I'll chase it up tomorrow for the next release.

> How about this fix in the attached patch?
>
>        Mox
>
> 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
>
>


More information about the cairo mailing list