FS#62251 - [ghostscript] Update to 9.27-1 breaks CUPS printing PDF documents

Attached to Project: Community Packages
Opened by Bogdan Szczurek (thebodzio) - Saturday, 06 April 2019, 04:31 GMT
Last edited by Andreas Radke (AndyRTR) - Monday, 08 April 2019, 09:17 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Andreas Radke (AndyRTR)
Architecture All
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
Recent update from Ghostscript 9.26-2 to 9.27-1 breaks CUPS printing PDF documents with foomatic-rip (from cups-filters). Any attempt to print PDF document ends up with “Filter failure” message in CUPS web frontend job list. The same kind of error, although described in greater detail, is present in /var/log/cups/error_log, given the appropriate LogLevel is set. error_log shows that the source of the problem is a failure of Ghostscript which, in turn, leads foomatic-rip to fail to properly read number of pages in given PDF document (reported numer of pages is “-1”).

Further investigation leads to filter/foomatic-rip/pdf.c file in cups-filters source code. In this file, function pdf_count_pages invokes Ghostscript with a couple of PostScript commands to get number of pages in PDF file. This piece of code is actually quite helpful for testing purposes. It can be conveniently run directly from command line. For example, if sample PDF file is “sampl.pdf”, we can run:

gs -dNODISPLAY -q -c '/pdffile (sample.pdf) (r) file def pdfdict begin pdffile pdfopen begin (PageCount: ) print pdfpagecount == flush currentdict pdfclose end end quit'

The expected output should look (depending on actual number of pages) something like:

PageCount: 23

It is exactly so for Ghostscript 9.26-2, while for 9.27-1 the output is:

Error: /undefined in pdfdict
Operand stack:

Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:731/1123(ro)(G)-- --dict:0/20(G)-- --dict:76/200(L)--
Current allocation mode is local
GPL Ghostscript 9.27: Unrecoverable error, exit code 1

This leads to pdf_count_pages to return -1 and effectively stop foomatic-rip altogether.

Both versions, however, are able to properly execute the following PostScript code, which gives exactly the same results:

gs -dNODISPLAY -q -c '/pdffile (sample.pdf) (r) file runpdfbegin (PageCount: ) print pdfpagecount = quit'

Unfortunately, I lack time to properly investigate what changes were done to Ghostscript since 9.26-2, so I can't be sure if, by a chance, the problem is caused by some planned deprecation. In that case the bug would be on foomatic-rip's side. It is certain, however, that some change in Ghostcript is responsible for the situation.

Additional info:
* Package version: 9.27-1

Steps to reproduce:

* Install newest Ghostscript 9.27-1, cups and cups-filters from repositories.
* Set up a printer.
* Attempt to print a PDF document
This task depends upon

Closed by  Andreas Radke (AndyRTR)
Monday, 08 April 2019, 09:17 GMT
Reason for closing:  Fixed
Additional comments about closing:  cups-filters 1.22.5-1
Comment by Andreas Radke (AndyRTR) - Saturday, 06 April 2019, 06:31 GMT
Please make sure you also have latest jbig2dec installed. Have you readded your printer to cups admin interface?

If it's still broken please ask first at irc #ghostscript channel. I'll try to find time to confirm this in the next few days.
Comment by Robert Kormann (RoKoInfo) - Saturday, 06 April 2019, 08:55 GMT
I can confirm Bogdan's observation on my system, having the following packages installed now with downgraded ghostscript:

x@y cups]$ pacman -Qs cups
local/cups 2.2.11-1
The CUPS Printing System - daemon package
local/cups-filters 1.22.4-1
OpenPrinting CUPS Filters
local/cups-pdf 3.0.1-4
PDF printer for cups
local/lib32-libcups 2.2.11-1
The CUPS Printing System - client libraries (32-bit)
local/libcups 2.2.11-1
The CUPS Printing System - client libraries and headers
[x@y cups]$ pacman -Qs ghostscript
local/ghostscript 9.26-2
An interpreter for the PostScript language

This combination is printing PDFs, the one with ghostscript 9.27-1 is not printing the same PDF.

Best regards
Robert
Comment by Bogdan Szczurek (thebodzio) - Saturday, 06 April 2019, 15:33 GMT
@Andreas:

Yes, I have the latest available jbig2dec installed (0.16-1). I actually tested this on two separate systems and both have the same, newest, package versions installed.

I didn't re-add my printer. I don't think this would change anything, given the offending Ghostscript invocation is constructed outside of PPD file, but to be certain I'll give it a try.

Unfortunately, I can't promise I'll be able to further investigate the Ghostscript changes, but I'll try to find some time to do so.


@Andreas and Robert:

Thank you for your time and effort. It is much appreciated.
Comment by Andreas Radke (AndyRTR) - Saturday, 06 April 2019, 18:54 GMT
I can confirm the bug here. Just asking @irc channel.
Comment by Andreas Radke (AndyRTR) - Sunday, 07 April 2019, 06:43 GMT
<ray_laptop> andyrtr: looks like nobody bothers with our release candidates. The problem is that in order to improve security by eliminating many "internals" of Ghostscipt, 'pdfdict' is no longer available, so: '/pdffile (sample.pdf) (r) file def pdfdict begin pdffile pdfopen begin (PageCount: ) print pdfpagecount == flush currentdict pdfclose end end quit'
<ray_laptop> andyrtr: these are undocumented 'internals' of Ghostscript. The documented, and still available, custom Ghostscript operator is "runpdfbegin".

No clue so far what part needs now fixing. I guess we should ask also Till about this.
Comment by Andreas Radke (AndyRTR) - Sunday, 07 April 2019, 15:05 GMT
Should be fixed with new cups-filters 1.22.5 release.

Loading...