Bug 2177856

Summary: PDF to PS conversion ends with error, but a PS file is generated
Product: [Fedora] Fedora Reporter: Zdenek Dohnal <zdohnal>
Component: ghostscriptAssignee: Richard Lescak <rlescak>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 38CC: akhaitovich, mjg, mosvald, rlescak, zdohnal
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-03-14 13:40:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Reproducer none

Description Zdenek Dohnal 2023-03-13 17:15:09 UTC
Description of problem:
If ghostscript is run with this command:

$ gs -q -dNOPAUSE -dBATCH -dSAFER -dNOMEDIAATTRS -sstdout=%stderr -sDEVICE=ps2write -dShowAcroForm -sOUTPUTFILE=%stdout -sProcessColorModel=DeviceGray -sColorConversionStrategy=Gray -dLanguageLevel=3 -r100 -dCompressFonts=false -dNoT3CCITT -dNOINTERPOLATE -c 'save pop' -f out.pdf > out.ps

it generates an error:

Error: /undefined in --runpdf--
Operand stack:
   --nostringval--   --dict:7/16(L)--   --dict:7/16(L)--   --dict:7/16(L)--   MediaBox   --nostringval--   0.0   0   false   (   **** Error: PDF interpreter encountered an error processing the file.\n)
Execution stack:
   %interp_exit   .runexec2   --nostringval--   runpdf   --nostringval--   2   %stopped_push   --nostringval--   runpdf   runpdf   false   1   %stopped_push   1974   1   3   %oparray_pop   1973   1   3   %oparray_pop   1961   1   3   %oparray_pop   1962   1   3   %oparray_pop   runpdf
Dictionary stack:
   --dict:775/1123(ro)(G)--   --dict:0/20(G)--   --dict:76/200(L)--   --dict:19/20(L)--
Current allocation mode is local
GPL Ghostscript 10.00.0: Unrecoverable error, exit code 1

which makes Ghostscript based filters to fail - however out.ps is populated.


Version-Release number of selected component (if applicable):
ghostscript-10.0.0-3.fc39.x86_64 (probably at F38 as well)

How reproducible:
Always

Steps to Reproduce:
1. take the command above and the attached PDF
2. run the command

Actual results:
An error is generated

Expected results:
No error

Additional info:
This issue currently blocks CUPS Fedora CI in Bodhi, because upstream test suite does not use the latest conv tables from cups-filters, but the users are not affected, because they use a different conv table.

Comment 1 Zdenek Dohnal 2023-03-13 17:15:53 UTC
Created attachment 1950287 [details]
Reproducer

Comment 2 Michael J Gruber 2023-03-14 09:12:54 UTC
Note that this fails with ghostscript-9.56.1-5.fc37.x86_64 already, with the same error.

OTOH, with `-dNEWPDF=false`, it gives a warning:

   **** Warning:  File has an empty MediaBox. Using the current page size instead.
                  Output may be incorrect.
   **** Warning:  File has an empty MediaBox. Using the current page size instead.
                  Output may be incorrect.

In any case, the input file `out.pdf` looks blank already, in any viewer. I can extract the image using `pdfimages`, of course. So I don't think the pdf is OK (though gs should not error out.)

I don't understand the remark about conv tables. Does this refer to something that cups uses in CI but not on user installs, but which you reproduce with the gs command line above?

Comment 3 Zdenek Dohnal 2023-03-14 13:40:26 UTC
Ouch, my bad, an elementary mistake - I didn't check the output of the previous filter which created the PDF... sorry for the noise.

Btw what is the current way for viewing Postscript files with Ghostscript? X11 device was removed and -sDEVICE=display segfaults (I'll file a separate bug).

> 
> I don't understand the remark about conv tables. Does this refer to
> something that cups uses in CI but not on user installs, but which you
> reproduce with the gs command line above?

Yes, but this is moot info right now, since the problem looks to lie in the previous filter.

Comment 4 Michael J Gruber 2023-03-14 13:53:58 UTC
(In reply to Zdenek Dohnal from comment #3)
> Ouch, my bad, an elementary mistake - I didn't check the output of the
> previous filter which created the PDF... sorry for the noise.
> 
> Btw what is the current way for viewing Postscript files with Ghostscript?
> X11 device was removed and -sDEVICE=display segfaults (I'll file a separate
> bug).

In which version do you think it is removed, and what does "gs -h" say?

x11 is the default device for gs ...
https://ghostscript.readthedocs.io/en/latest/Devices.html#x-window-system

Comment 5 Zdenek Dohnal 2023-03-14 14:50:09 UTC
(In reply to Michael J Gruber from comment #4)
> (In reply to Zdenek Dohnal from comment #3)
> > Ouch, my bad, an elementary mistake - I didn't check the output of the
> > previous filter which created the PDF... sorry for the noise.
> > 
> > Btw what is the current way for viewing Postscript files with Ghostscript?
> > X11 device was removed and -sDEVICE=display segfaults (I'll file a separate
> > bug).
> 

$ gs -sDEVICE=x11 ps
GPL Ghostscript 10.0.0 (2022-09-21)
Copyright (C) 2022 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Unknown device: x11

> In which version do you think it is removed, and what does "gs -h" say?
> 

It was removed in 10.0.0, Fedora CI caught it, but Risa talked with upstream and I understood it as it was intentionally removed upstream.

$ rpm -q ghostscript
ghostscript-10.0.0-3.fc38.x86_64

$ gs -h
...
Available devices:
   alc1900 alc2000 alc4000 alc4100 alc8500 alc8600 alc9100 ap3250 appledmp
...
   tiffsep1 txtwrite uniprint urf xcf xes xpswrite

> x11 is the default device for gs ...
> https://ghostscript.readthedocs.io/en/latest/Devices.html#x-window-system

I'll ask upstream to be sure, but certainly it was removed in gs 10.0.0 rebase.