Bug 1530268 - a2ping doesn't work with ghostscript 9.22
Summary: a2ping doesn't work with ghostscript 9.22
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: texlive
Version: 27
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Tom "spot" Callaway
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-01-02 12:19 UTC by akiyks
Modified: 2018-11-02 11:50 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-11-02 11:50:14 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Sample eps file (generated by fig2eps) (12.03 KB, application/postscript)
2018-01-02 12:19 UTC, akiyks
no flags Details
gs command file extracted from a2ping.pl (4.52 KB, text/plain)
2018-01-11 11:37 UTC, akiyks
no flags Details
Minimal patch to a2ping.pl 2.77 (1.83 KB, patch)
2018-03-11 10:51 UTC, akiyks
no flags Details | Diff

Description akiyks 2018-01-02 12:19:49 UTC
Created attachment 1375688 [details]
Sample eps file (generated by fig2eps)

Description of problem:

After update to ghostscript 9.22, a2ping aborts with error from gs.

Version-Release number of selected component (if applicable):
ghostscript 9.22-3.fc27

How reproducible:
Run a2ping (need "texlive-a2ping" package) with the attached circle.eps
as input. (Any eps file shows the same symptom.)

Steps to Reproduce:
1. Run command:

$ a2ping -v --bboxfrom=compute-gs circle.eps circle.pdf

Actual results:

$ a2ping -v --bboxfrom=compute-gs circle.eps circle.pdf
a2ping.pl 2.77p, 2006-11-15 -- Written by <pts> from April 2003.
This is free software, GNU GPL >=2.0. There is NO WARRANTY.
(epstopdf 2.7 Copyright 1998-2001 by Sebastian Rahtz et al.)

* Strongest BoundingBox comment: %%HiResBoundingBox:
* Doing --PaperSize unchanged
* Output filename: circle.pdf
* Output FileFormat: PDF
* Ghostscript ps2pdf command: gs  
* Compression: zip
* Input filename: circle.eps
* Computing BBox info from non-EPS PS file
* Ghostscript compute pipe: gs -dWRITESYSTEMDICT -dNOPAUSE -sDEVICE=bbox -sFN=circle.eps /tmp/a2ping_pl-3226-178004406-c.tgs 2>&1
/usr/bin/a2ping: not a GS output from gs (256)

Expected results:

By downgrading to ghostscript 9.20-14.fc27, the same command succeeds as
follows.

$ a2ping -v --bboxfrom=compute-gs circle.eps circle.pdf
a2ping.pl 2.77p, 2006-11-15 -- Written by <pts> from April 2003.
This is free software, GNU GPL >=2.0. There is NO WARRANTY.
(epstopdf 2.7 Copyright 1998-2001 by Sebastian Rahtz et al.)

* Strongest BoundingBox comment: %%HiResBoundingBox:
* Doing --PaperSize unchanged
* Output filename: circle.pdf
* Output FileFormat: PDF
* Ghostscript ps2pdf command: gs  
* Compression: zip
* Input filename: circle.eps
* Computing BBox info from non-EPS PS file
* Ghostscript compute pipe: gs -dWRITESYSTEMDICT -dNOPAUSE -sDEVICE=bbox -sFN=circle.eps /tmp/a2ping_pl-2337-475517213-c.tgs 2>&1
* Applying BoundingBox from Compute-GS T-: 157 3147 238 3229
* Applying HiResBoundingBox from Compute-GS T-H: 157.002183 3147.614974 237.867743 3228.480394
* Scanning header for BoundingBox
* Final (HiRes)BoundingBox: 157.002183 3147.614974 237.867743 3228.480394
* Ghostscript ps2pdf pipe: gs -q -dBATCH -sDEVICE=pdfwrite  -sOutputFile=circle.pdf -
* Ghostscript dup pipe: gs -dNODISPLAY -dBATCH -sFN=circle.pdf -q /tmp/a2ping_pl-2337-173686660-p.tgs
GPL Ghostscript 9.20: Unrecoverable error, exit code 1
* warning: gs failed to locate double /MediaBox
* Done OK, created PDF file circle.pdf (1213 bytes)

Additional info:

gs 9.20 does emit an error message, but pdf output is OK for inclusion to
LaTeX documents.

As "a2ping" is quite an old script, this might be intentional change 
in 9.22. If that is the case, I need to find alternative means to
generate proper pdf output.

Comment 1 David Kaspar // Dee'Kej 2018-01-02 13:28:12 UTC
Well, I will need a reproducer just for ghostscript if I am suppose to take this to upstream to get it resolved.

However, this might be a case where the a2ping script was not yet adapted to changes that taken place in ghostscript-9.22, which is not a problem on ghostscript side.

I'm switching this BZ to texlive maintainer. Maybe they can tell us more.

Comment 2 Tom "spot" Callaway 2018-01-09 19:52:04 UTC
a2ping.pl has not seen any changes in a very long time. It's possible that it needs changes to reflect the new ghostscript, but I could not find anything obvious.

Comment 3 akiyks 2018-01-10 15:13:33 UTC
So what would be a next step?
As David suggested, if I can somehow extract a2ping's temporary input and
options to "gs", and compare the result in ghostscript 9.20 and 9.22,
would it be some clue?

Comment 4 David Kaspar // Dee'Kej 2018-01-10 16:00:06 UTC
(In reply to akiyks from comment #3)
> So what would be a next step?
> As David suggested, if I can somehow extract a2ping's temporary input and
> options to "gs", and compare the result in ghostscript 9.20 and 9.22,
> would it be some clue?

I was actually trying to do that thing myself before, but I wasn't successful and hadn't had so much time to look into it... :-/

We can see with what parameters the ghostscript was called:
> gs -dWRITESYSTEMDICT -dNOPAUSE -sDEVICE=bbox -sFN=circle.eps /tmp/a2ping_pl-3226-178004406-c.tgs 2>&1

For the start, it might be good to compare results of this command for 9.20 and 9.22. In case it doesn't work in both cases, then we need to figure out how exactly is ghostscript being called/used inside the a2ping.

Comment 5 akiyks 2018-01-11 11:37:14 UTC
Created attachment 1379959 [details]
gs command file extracted from a2ping.pl

Comment 6 akiyks 2018-01-11 11:51:57 UTC
(In reply to David Kaspar [Dee'Kej] from comment #4)
> [...]
> I was actually trying to do that thing myself before, but I wasn't
> successful and hadn't had so much time to look into it... :-/
> 
> We can see with what parameters the ghostscript was called:
> > gs -dWRITESYSTEMDICT -dNOPAUSE -sDEVICE=bbox -sFN=circle.eps /tmp/a2ping_pl-3226-178004406-c.tgs 2>&1
> 
> For the start, it might be good to compare results of this command for 9.20
> and 9.22. In case it doesn't work in both cases, then we need to figure out
> how exactly is ghostscript being called/used inside the a2ping.

So, I could extract the temp gs command file embedded in a2ping.pl and
attached it.

If you name it "a2ping-gs-bbox.tgs", running gs 9.20 will output the following:

-------
$ gs -dWRITESYSTEMDICT -dNOPAUSE -sDEVICE=bbox -sFN=circle.eps a2ping-gs-bbox.tgs 2>&1
GPL Ghostscript 9.20 (2016-09-26)
Copyright (C) 2016 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
%%BoundingBox: 157 3147 238 3229
%%HiResBoundingBox: 157.002183 3147.614974 237.867743 3228.480394
bbox-begin
pop-count==0
end-count==1
cut-offset==12261
bbox-success
-------

gs 9.22 ends up in the following error:

-------
$ gs -dWRITESYSTEMDICT -dNOPAUSE -sDEVICE=bbox -sFN=circle.eps a2ping-gs-bbox.tgs 2>&1
GPL Ghostscript 9.22 (2017-10-04)
Copyright (C) 2017 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /undefined in --.beginpage--
Operand stack:
   false   --dict:1/1(L)--   --nostringval--   --dict:79/156(ro)(L)--   --dict:1/1(L)--   --dict:0/0(L)--   --dict:79/88(ro)(L)--   0
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1999   1   3   %oparray_pop   1998   1   3   %oparray_pop   1982   1   3   %oparray_pop   1868   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   1961   1   3   %oparray_pop   --nostringval--   1963   7   3   %oparray_pop   --nostringval--   1955   7   3   %oparray_pop   --nostringval--   9
Dictionary stack:
   --dict:981/1684(G)--   --dict:0/20(G)--   --dict:82/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
Current file position is 488
GPL Ghostscript 9.22: Unrecoverable error, exit code 1
--------

David, does this qualify as "a reproducer just for ghostscript"?

Thanks.

Comment 7 David Kaspar // Dee'Kej 2018-01-11 12:11:28 UTC
(In reply to akiyks from comment #6)
> David, does this qualify as "a reproducer just for ghostscript"?

I would say it does! :) I will take a look at this as soon as I can, and report it to upstream if this really is a regression in 9.22... ;)

Comment 8 akiyks 2018-02-17 02:59:05 UTC
(In reply to David Kaspar [Dee'Kej] from comment #7)

> I would say it does! :) I will take a look at this as soon as I can, and
> report it to upstream if this really is a regression in 9.22... ;)

Hello David,

It's been a while since the last update.
I assume you are the assignee, but this ticket is still assigned to Tom.

Could you change the assignee?

And if there is any update on this issue you can share, please let me know.

Thanks, Akira

Comment 9 David Kaspar // Dee'Kej 2018-02-21 14:09:14 UTC
Hello Akira,

sorry for the late reply, I got caught by other responsibilities. Anyway, I have tried the reproducer with 9.20 version of Ghostscript, but I keep seeing this:

$ gs -dWRITESYSTEMDICT -dNOPAUSE -sDEVICE=bbox -sFN=circle.eps a2ping-gs-bbox.tgs 2>&1
GPL Ghostscript 9.20 (2016-09-26)
Copyright (C) 2016 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /undefinedfilename in --file--
Operand stack:
   MAINFILE   (circle.eps)   (r)
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1983   1   3   %oparray_pop   1982   1   3   %oparray_pop   1966   1   3   %oparray_pop   1852   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:1203/1684(G)--   --dict:0/20(G)--   --dict:79/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
Current file position is 92
GPL Ghostscript 9.20: Unrecoverable error, exit code 1

-------------------

Maybe I'm doing something wrong? I'm installing Rawhide (again) in VM to test it with 9.22 as well.

Comment 10 akiyks 2018-02-21 14:56:54 UTC
(In reply to David Kaspar [Dee'Kej] from comment #9)

Hello David,

So circle.eps is the name of the attachment #1 [details] of this ticket.

Can you try with the file downloaded?

Thanks!

Comment 11 David Kaspar // Dee'Kej 2018-02-23 16:17:05 UTC
So, upstream has responded:

(In reply to Ken Sharp from https://bugs.ghostscript.com/show_bug.cgi?id=699063#c2)
> Yeah basically that's not going to work in 9.22, at all.
> 
> As it stands the prolog file will only ever work using Ghostscript, because
> it is using a Ghostscript-specific non-standard operator (.callbeginpage)
> and relies on systemdict being writeable (which it is not supposed to be).
> We removed almost all the non-standard operators as part of the 9.22
> security hardening process, and I'm not in any hurry to put any of them back
> again.
> 
> As we've said on a number of occasions, if the maintainers of the package
> want to talk to us we can discuss what they can do about it. We need to
> discuss it because I don't understand the point of the program and don't
> want to spend lots of time working through it to figure out what its doing.
> If we can't figure out some other solution then we can restore the operator,
> but I'd bet the use of the non-standard operator isn't required.
> 
> In the forthcoming 9.23 release it can be worked around by specifying
> -dDELAYBIND, provided the user accepts the security hole (but since they are
> using -dWRITESYSTEMDICT their security model is potentially wide open if
> someone maliciously alters the prolog of this file anyway).
> 
> I'll leave this open for a bit in case you can find the maintainer.

This confirms the git-bisect I was doing to check the issue. I'm switching this to texlive - maybe the upstream there would like ot update the a2ping utility.

However, from my point of view it's a definitely WONTFIX for Ghostscript.

Best regards,

 -- Dee'Kej --

Comment 12 akiyks 2018-02-23 23:57:57 UTC
(In reply to David Kaspar [Dee'Kej] from comment #11)

I see.

I've changed the Summary to reflect the situation.
I'll keep this ticket open for a while with a faint hope that a2ping can be fixed.

In the meantime, I'll see any alternative means is available.

Thanks for your help.

Comment 13 David Kaspar // Dee'Kej 2018-02-26 13:23:38 UTC
There's another reply from Ray Johnston which provides sort of a workaround/fix for this. However, someone would have to dig deep inside the a2ping to fix it, but I don't have time for that...

Comment 14 akiyks 2018-02-26 14:36:30 UTC
(In reply to David Kaspar [Dee'Kej] from comment #13)
> There's another reply from Ray Johnston which provides sort of a
> workaround/fix for this. However, someone would have to dig deep inside the
> a2ping to fix it, but I don't have time for that...

Thank you for letting me know!

I'll try to apply the suggested patch to a2ping.pl and see if it works.
Give me a few days.

Comment 15 Tom "spot" Callaway 2018-02-26 20:37:09 UTC
If you figure out a working patch, let me know, I will apply it.

Comment 16 akiyks 2018-03-02 15:09:32 UTC
Hi, all. Just a status update.

Luckily, I've got a response from the maintainer of a2ping.pl, Péter Szabó.
He suggested a slightly different fix than Ray Johnston's.
I've confirmed both fixes work with gs 9.20 (and earlier versions) and gs 9.22.
I'm awaiting his choice between the two fixes (or a better mid point).

Hopefully I should be able to report back shortly.

Thanks!

Comment 17 David Kaspar // Dee'Kej 2018-03-05 09:47:02 UTC
(In reply to akiyks from comment #16)
> Hi, all. Just a status update.
> 
> Luckily, I've got a response from the maintainer of a2ping.pl, Péter Szabó.
> He suggested a slightly different fix than Ray Johnston's.
> I've confirmed both fixes work with gs 9.20 (and earlier versions) and gs
> 9.22.
> I'm awaiting his choice between the two fixes (or a better mid point).
> 
> Hopefully I should be able to report back shortly.
> 
> Thanks!

Thanks a lot for taking this initiative, Akira! :)

Comment 18 akiyks 2018-03-11 10:51:17 UTC
Created attachment 1406838 [details]
Minimal patch to a2ping.pl 2.77

Comment 19 akiyks 2018-03-11 11:38:03 UTC
Hi all,

It turned out Péter did some update to a2ping.pl but didn't uploaded
CTAN, but published elsewhere. In response to this bug report,
he did some archaeology and shared his update including the compatibility
fix with Ghostscript 9.22 at https://github.com/pts/a2ping.
He has also uploaded the update to CTAN at https://www.ctan.org/pkg/a2ping.

Current version there is 2.83p. (Note that version 2.77p mostly
corresponds to 2.81p in the github repository.)

However, I guess Fedora's texlive maintainers would not feel like
applying changes including feature update upto 2.83p.

So I composed a minimal patch that contains only the compatibility
fix relative to 2.77p attached above. This patch has got Péter's ack.
The version assigned here is "2.77p1".

Péter's fix is different from the one suggested at Ghostscript bugzilla
in the following points:

  (a) keep the switching to/from systemdict,
  (b) adds a command stream which is equivalent to .callbeginpage,
  (c) does not add /NOPAUSE because the command line invoking the temp
      gs script already has "-dNOPAUSE".

(a) and (b) seem irrelevant to the example appended here especially
on Linux, but Péter wants to keep backward compatibility of the
script for other configurations/platforms.

The bottom hunk of the patch adds an entry in revision history.
It is a verbatim copy of an entry in HISTORY.txt, give or take the
version identifier, "2.77p1".

The timing of the upload to CTAN should meet the dead line of
TeX live 2018 release, but I think it will take a while a2ping of
Fedora is updated to 2.83p.

Both 2.83p and 2.77p1 work fine with Gostscript versions 9.10, 9.18,
9.20, and 9.22.

Tom, does the appended patch look reasonable to you?

Thanks!

Comment 20 Fedora Update System 2018-03-13 19:52:12 UTC
texlive-2016-37.20160520.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2018-7e9e216bc2

Comment 21 Fedora Update System 2018-03-14 20:44:03 UTC
texlive-2016-37.20160520.fc27 has been pushed to the Fedora 27 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-7e9e216bc2

Comment 22 akiyks 2018-03-15 13:00:31 UTC
(In reply to Fedora Update System from comment #21)
> texlive-2016-37.20160520.fc27 has been pushed to the Fedora 27 testing
> repository. If problems still persist, please make note of it in this bug
> report.
> See https://fedoraproject.org/wiki/QA:Updates_Testing for
> instructions on how to install test updates.
> You can provide feedback for this update here:
> https://bodhi.fedoraproject.org/updates/FEDORA-2018-7e9e216bc2

I've installed texlive-2016-37.20160520.fc27, but the a2ping.pl is identical to
what it was before.

Time stamp of /usr/bin/a2ping (which is a symbolic link to
/usr/share/texlive/texmf-dist/scripts/a2ping/a2ping.pl) is updated,
but the perl script itself has the time stamp of May 14, 2008.

What am I missing?

Comment 23 David Kaspar // Dee'Kej 2018-03-21 17:49:19 UTC
There's one more comment from Ken in Ghostscript's BZ:
https://bugs.ghostscript.com/show_bug.cgi?id=699063#c5

Comment 24 akiyks 2018-03-29 15:30:18 UTC
Hi,

So I see 2nd attempt to actually apply the patch to a2ping.pl failed in
the s390x build:

https://koji.fedoraproject.org/koji/taskinfo?taskID=25731877

Do you have any prospect of updating a2ping.pl in a short while?
If it is not likely, I'll start advertising the availability of a2ping 2.83p
at CTAN within an open source textbook community I'm involved with.

Comment 25 akiyks 2018-11-02 11:50:14 UTC
Now that Fedora 29 has a2ping 2.83p in its Tex Live package, I'm closing this one.
Thanks.


Note You need to log in before you can comment on or make changes to this bug.