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

Knut Petersen knupero at gmail.com
Sat Jul 24 12:08:29 UTC 2021


Hi Uli,
> 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 bigger 3-page test document generates the sequence

create
[drawing commands]
show_page
[drawing commands]
show_page
[drawing commands]
show_page
finish

for ps and pdf files. For the svg three files are generated, each with the following sequence

create
[drawing commands]
show_page
finish

After each showpage/finish both context status and surface status are evaluated. The test is started on a file system with no space left. Here are the results:

PDF backend:  Context status reports a write error after the very first show_page. Perfect. File size of the pdf file on a non-full file system: 102906 Bytes. But your test fails ... could this depend on the amount of data to be written?

PS backend: No error for any context status, but the surface status after cairo_finish correctly reports a write error. File size of the ps file on a non-full file system: 516973 Bytes. Your test also reports an error. Fine.

SVG backend: No error for any context status, no error for any surface status. Expected file sizes for the three output files on a non-full file system: 265707 Bytes, 22609 Bytes, 45018 Bytes. Your test program does not contain a svg test, I added such a test. That test also incorrectly reports 
success on a full file system. So the svg backend is definitely still broken.

Reason for my false ps bug report: Starting with cairo pdf code I had the impression that it is enough to evaluate the  context status, so I did not evaluate the surface status at the end of the ps write. So I agree, the PS backend is not really broken, maybe it detects errors a bit late?

Attached the extended test program. It reports:

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

no error has occurred for svg after show page
no error has occurred for svg for surface
no error has occurred for svg for surface after finish

Knut

-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.c
Type: text/x-csrc
Size: 890 bytes
Desc: not available
URL: <https://lists.cairographics.org/archives/cairo/attachments/20210724/d6c9aab7/attachment.c>


More information about the cairo mailing list