[cairo] BUG: Cairo reports CAIRO_STATUS_SUCCESS even if writing to disk failed (SVG and PS backend)

Uli Schlachter psychon at znc.in
Fri Jul 23 15:30:21 UTC 2021


Hi,

Am 23.07.21 um 15:28 schrieb Knut Petersen:
[...]
> AFAICS it's cairo_show_page that triggers the actual writing to disk, so
> the test should be at the right place.

There is definitely still writing going on cairo_surface_finish() (which
is called implicitly for you from cairo_surface_destroy() when
destroying the last reference to a surface.

Anyway, I now tried to reproduce your report. My code is attached. It
lets cairo write to /dev/full and checks what happens.

Output for me is "no errors are reported" for pdf (which is wrong!), but
ps actually properly reports the problem:


$ ./a.out
no error has occurred for pdf after show page
no error has occurred for pdf for surface
no error has occurred for pdf for surface after finish

no error has occurred for ps after show page
no error has occurred for ps for surface
error while writing to output stream for ps for surface after finish


The above confuses me, since you write that pdf works fine for you, but
ps does not report errors. Could you double check and perhaps provide
some reproducer (e.g. based on /dev/full)?

I opened a MR for the bug in the pdf backend:
https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/210

With this patch, I get:


$ ./a.out
no error has occurred for pdf after show page
no error has occurred for pdf for surface
error while writing to output stream for pdf for surface after finish

no error has occurred for ps after show page
no error has occurred for ps for surface
error while writing to output stream for ps for surface after finish


(At least I have some insight why there is no error yet after
cairo_show_page(): fwrite() does buffering. Only after a fflush() does
libc actually try to write this small file and only then an error
actually occurs. That's why there is no error status yet after
cairo_show_page().)

Cheers,
Uli
-- 
<alanc> I think someone had a Xprint version of glxgears at one point,
    but benchmarking how many GL pages you can print per second
    was deemed too silly to merge


More information about the cairo mailing list