[cairo] cairo_device_finish: Set "->finished = TRUE" only after backend callback

Uli Schlachter psychon at znc.in
Wed Feb 9 11:29:38 PST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi list,

I noticed that the xcb-surface-source test fails for all the vector-based
backends (svg, pdf, ps, recording). Taking a closer look at this, I noticed that
cairo_device_acquire was called on a finished device:

 #0  cairo_device_acquire (device=0x690f70) at cairo-device.c:414
 #1  0x00007ffff7b884fb in _cairo_xcb_connection_acquire (surface=0x69c610,
use_shm=<value optimized out>, image_out=0x7fffffffcc58) at cairo-xcb-private.h:246
 #2  _get_image (surface=0x69c610, use_shm=<value optimized out>,
image_out=0x7fffffffcc58) at cairo-xcb-surface.c:425
 #3  0x00007ffff7b893cf in _cairo_xcb_surface_acquire_source_image
(abstract_surface=0x69c610, image_out=0x7fffffffcce8, image_extra=0x7fffffffcce0)
     at cairo-xcb-surface.c:561
 #4  0x00007ffff7b601d4 in _cairo_surface_acquire_source_image
(surface=0x690f70, image_out=0x7fffffffcce8, image_extra=0x0) at
cairo-surface.c:1458
 #5  0x00007ffff7b65dcf in _cairo_surface_snapshot_copy_on_write (surface=<value
optimized out>) at cairo-surface-snapshot.c:125
 #6  0x00007ffff7b609b1 in _cairo_surface_detach_snapshot (snapshot=0x690f70) at
cairo-surface.c:330
 #7  0x00007ffff7b606dc in _cairo_surface_detach_snapshots (surface=0x69c610) at
cairo-surface.c:315
 #8  cairo_surface_flush (surface=0x69c610) at cairo-surface.c:1126
 #9  0x00007ffff7b6074d in cairo_surface_finish (surface=0x690f70) at
cairo-surface.c:718
 #10 0x00007ffff7b881ff in _cairo_xcb_screen_finish (screen=0x691920) at
cairo-xcb-screen.c:61
 #11 0x00007ffff7b8629c in _device_finish (device=0x690f70) at
cairo-xcb-connection.c:546
 #12 0x0000000000446f7c in cleanup (data=0x69c370) at xcb-surface-source.c:47
 #13 0x00007ffff7b1e56a in _cairo_user_data_array_fini (array=0x693628) at
cairo-array.c:390
 #14 0x00007ffff7b60868 in cairo_surface_destroy (surface=0x693600) at
cairo-surface.c:651
 #15 0x0000000000447599 in draw (cr=0x7ffff7ddc288, width=<value optimized out>,
height=<value optimized out>) at surface-source.c:149
[...]

The problem is that cairo-xcb still has to use the device in it's
cairo_device_finish callback because it has to e.g. free Pictures and, as in the
above backtrace, get images from the X11 server.

My proposed fix is to change cairo_device_finish to only set the device to
finished after the backend's callback returns. (Patch attached)

I took a look at all the other backends grepping for cairo_device_backend_t. It
looks like all the other backends have trivial device finish callbacks and so I
hope that nothing will break.

Any objections? Better ideas? Obvious mistakes that I am overlooking?

Cheers,
Uli

- -- 
- - Buck, when, exactly, did you lose your mind?
- - Three months ago. I woke up one morning married to a pineapple.
  An ugly pineapple... But I loved her.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEcBAEBCAAGBQJNUusgAAoJECLkKOvLj8sGy8YIAK6IWiA7TChpTQdTJ41ps40N
ydp3uNlcUiGdd0A1LfkK1i78ndzYD17dOTlwuMIW08AucYcb8k/D9QY86LcU8kBH
e3trLEFcpuH9VPQGpTw4iNwa/I4IJT7mc2N6vL74rV/mDEEDnrT87J6daz5VFbd+
VOhh68uagUvohoRjXaSkB+2kX7lQUtBJnC3yoFXi3UcRAFiNwUfOp/oMO8WfvZZN
CtmHUmUIpu1jBf5+r2z2NRwu03thM9ZIJTiRsP2Bk4rsBu/T2kxuxTAyzWUDYYOS
fURwHaAY9y+qD5m/EYd0Xtp5cchDXZOTNwdMZyTvodqjIvBzYVfFRg/JM0TB0kw=
=TrGs
-----END PGP SIGNATURE-----


More information about the cairo mailing list