Bug 1632030

Summary: Postscript extensions not available anymore
Product: [Fedora] Fedora Reporter: Ulrich Drepper <drepper>
Component: ghostscriptAssignee: David Kaspar // Dee'Kej <deekej>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 28CC: deekej, twaugh, zdohnal
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-09-23 15:32:28 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:

Description Ulrich Drepper 2018-09-23 15:12:20 UTC
Description of problem:
ghostscript defines some extensions over the standard to support, among other features, opacity. This is needed to generate PDFs via .eps etc, used for instance by asymptote.

After version 9.23-6 this seems to be disabled.

I tried version 9.24-1 and the current 9.25-1 without success.

Version-Release number of selected component (if applicable):
9.24-1 and later

How reproducible:
always

Steps to Reproduce:
1. use this file as an example: https://github.com/joneslee85/ruby-ghostscript/blob/master/vendor/ghostscript-9.05/examples/transparency_example.ps
2. run 'gs -q -dNOPAUSE -dBATCH -P -dSAFER -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -sOutputFile=transparency_example.pdf transparency_example.ps'
3.

Actual results:
Error: /undefined in .setopacityalpha
Operand stack:
   0.5
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   2015   1   3   %oparray_pop   2014   1   3   %oparray_pop   1998   1   3   %oparray_pop   1884   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:968/1684(ro)(G)--   --dict:0/20(G)--   --dict:79/200(L)--
Current allocation mode is local
Current file position is 583
GPL Ghostscript 9.24: Unrecoverable error, exit code 1


Expected results:
no output, correct PDF produced

Additional info:
as mentioned above, this breaks asymptote which is how I noticed

Comment 1 Ulrich Drepper 2018-09-23 15:32:28 UTC
After a bit more digging and comparing old versions with new once I found that the issue is -dSAFER.  The extensions were always declared insecure but apparently because the test suite uses them were not disabled.  In 9.24 this seems to have changed.  Removing the -dSAFER option allows to PS file to be translated.

Seems asymptote needs to remove the use of -dSAFER.

Comment 2 David Kaspar // Dee'Kej 2018-09-24 08:52:07 UTC
(In reply to Ulrich Drepper from comment #1)
> Seems asymptote needs to remove the use of -dSAFER.

No, this is wrong. What happened is that Ghostscript disabled some of the non-standard PS, which I guess was used by asymptote. Using non-standard PS (PS extensions) comes with a risk that the behaviour might change over time, which is what happened here.

So in this case, the asymptote needs to figure out what it is doing wrong, because there should be a way to achieve the same result with using the standard PS, or just changing their extended PS code slightly.

Removing the use of -dSAFER is really dangerous thing to do, especially in the wake of many exploits regarding -dSAFER in last 2 years...