Bug 703706

Summary: "Error: /undefined in GS_PDF_ProcSet" when processing a PDF
Product: Ghostscript Reporter: programming
Component: GeneralAssignee: Chris Liddell (chrisl) <chris.liddell>
Status: RESOLVED FIXED    
Severity: normal CC: chris.liddell
Priority: P4    
Version: 9.53.3   
Hardware: PC   
OS: Linux   
Customer: Word Size: ---
Attachments: FRP.pdf
import.prolog

Description programming 2021-03-17 16:45:03 UTC
Created attachment 20823 [details]
FRP.pdf

When trying to process a PDF, I encounter the following error in ghostscript:

$ gs -q -dNOPAUSE -dNODISPLAY -dBATCH -dDELAYBIND -g1451x1089 -r288 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -c 0 0 translate -sTraceFile=/home/turion/.scribus//ps.out -sExportFiles=/home/turion/Nextcloud/Dokument--FRP /nix/store/42igv4wq4bavyf4h14rcb5v54gk4sjsx-scribus-1.4.8/lib/scribus/import.prolog /home/turion/Nextcloud/FRP.pdf -c flush cfile closefile quit
 
 *** WARNING - you have selected SAFER, indicating you want Ghostscript
               to execute in a safer environment, but at the same time
               have selected DELAYBIND. Unless you use this option with
               care (and specifically, remember to call .bindnow) it is
               possible that malicious code may be able to evade the
               limited security offered by the SAFER option.
Error: /undefined in GS_PDF_ProcSet
Operand stack:
   false
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1974   1   3   %oparray_pop   1973   1   3   %oparray_pop   1961   1   3   %oparray_pop   1818   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:1175/1684(ro)(G)--   --dict:0/20(G)--   --dict:76/200(L)--
Current allocation mode is global
Current file position is 2202
GPL Ghostscript 9.53.3: Unrecoverable error, exit code 1


I found this by opening it in Scribus (which calls ghostscript).

It fails for many (all?) other PDFs as well. My operating system is NixOS.
Comment 1 programming 2021-03-17 16:45:52 UTC
Note that this PDF is generated with LaTeX, but it also fails with other PDFs, some exported from Microsoft Office, some generated entirely differently.
Comment 2 Chris Liddell (chrisl) 2021-03-17 17:46:49 UTC
Since that PDF file opens just fine with Ghostscript 9.53.3 "normally", the problem is likely to be in "/nix/store/42igv4wq4bavyf4h14rcb5v54gk4sjsx-scribus-1.4.8/lib/scribus/import.prolog" file (which you haven't supplied).

Which, based on the error, is *probably* because they are using (or trying to use) Ghostscript in an undocumented and unsupported way. Basically, using internal stuff that is subject to change (and has changed).

I would suggest that you report the problem to the scribus developers, directing them to this bug report (or to #ghostscript on freenode, or the gs-devel mailing list), and we'll be happy to work with them to work out solution that *is* supported.
Comment 3 programming 2021-03-17 18:02:54 UTC
Created attachment 20824 [details]
import.prolog

Good point. I added it as an attachment. I don't really understand its contents. Does it constitute a valid or invalid way of using ghostscript? (If the latter, I'll gladly open a scribus bug.)
Comment 4 Ken Sharp 2021-03-17 18:10:57 UTC
(In reply to programming from comment #3)
> Created attachment 20824 [details]
> import.prolog
> 
> Good point. I added it as an attachment. I don't really understand its
> contents. Does it constitute a valid or invalid way of using ghostscript?
> (If the latter, I'll gladly open a scribus bug.)

Amongst other things it uses .forceput which is a non-standard extension in Ghostscript and specifically prohibited in SAFER mode because it is a security hole.

Recent versions of Ghostscript default to SAFER mode (as we've been threatening for, literally, years).

Essentially this Scribus code isn't going to work with Ghostscript without setting -dNOSAFER and it definitely uses portions of the current PDF interpreter which are not intended as public, should not be used, and in future will not be available.

The Scribus developers are going to have to discuss this with us because what they are doing here is definitely not going to work in future, regardless of SAFER/NOSAFER.
Comment 5 programming 2021-03-17 19:14:49 UTC
I reported it here: https://bugs.scribus.net/view.php?id=16520

Your hint was great: Scribus developers have in fact already reacted since some time, apparently. I was using an older version, and in the updated Scribus version the import worked. Thanks!
Comment 6 Chris Liddell (chrisl) 2021-03-17 19:41:08 UTC
(In reply to programming from comment #5)
> I reported it here: https://bugs.scribus.net/view.php?id=16520
> 
> Your hint was great: Scribus developers have in fact already reacted since
> some time, apparently. I was using an older version, and in the updated
> Scribus version the import worked. Thanks!

That's great, thanks for reporting back.

And apologies for the upheaval - we do try hard not to introduce incompatible changes, but in this case, we ended up with no choice.