Reply to topic  [ 10 posts ] 
BoundingBox bug? 
Author Message

Joined: Mon Feb 18, 2008 9:41 am
Posts: 9
Post BoundingBox bug?
Hello.

First post for me :)

I loaded the Ubuntu repository on maunae.net. It works great. It immediately urged me to update my yorick to the version 2.01.05x. I did the update, but now my "eps" and "pdf" functions have the bounding box screwed.

If I type:
$ yorick
Copyright (c) 2005. The Regents of the University of California.
All rights reserved. Yorick 2.1.05x ready. For help type 'help'
> plg,[0,1]
> eps,"test"
>

here is the header of the file test.eps :
%!PS-Adobe-2.0 EPSF-1.2
%%Title: Yorick 0
%%For: slacou
%%CreationDate: Wed Feb 20 16:26:45 2008
%%Creator: Gist
%%BoundingBox: 153 344 422 614
%%HiResBoundingBox: 153.773995 344.753989 421.307987 613.133981
save countdictstack mark newpath /showpage {} def /setpagedevice {pop} def
%%EndProlog
%
% Gist PostScript Prolog
% $Id: ps.ps,v 1.2 2007/06/29 15:09:20 dhmunro Exp $
% Copyright (c) 1994. The Regents of the University of California.
% All rights reserved.
%

And the bounding doesn't include the whole window. Only the curve. Do you have the same effect?
Here is the file:
http://www.physics.usyd.edu.au/~slacour/f/test.eps

Sylvestre

ps: I disabled the my custom.i file before doing that test.


Wed Feb 20, 2008 7:32 am
Profile WWW
Yorick Master

Joined: Sun Sep 26, 2004 10:33 am
Posts: 150
Location: Australia
Post 
Sylvestre,

Thanks for bringing that up.
I noticed the same thing recently. Was wondering what i did to mess things up, but apparently you got the same bug.

I am going to investigate. I really don't see how this could be related to the packaging itself, but I will also check in that direction.

Will keep you up to date.

oh, one question: what version of ubuntu are you using? gutsy? that may be a ghostscript bug...

anyone running 2.1.05 on a different distro? do you notice the same bug?


Fri Feb 22, 2008 6:51 am
Profile WWW
Yorick Master

Joined: Sun Sep 26, 2004 10:33 am
Posts: 150
Location: Australia
Post 
ok, I have tracked this down to a modification that david made on 2007/05/18:
Code:
revision 1.3
date: 2007/05/18 01:32:06;  author: dhmunro;  state: Exp;  lines: +2 -2
fix gs -dSAFER incompatibility with bbox on some systems, fixes pdf, eps

The modif (I checked) was just to remove the flag -dSAFER from the ghostscript command that yorick is spawning to create the ps/eps/epsi.

I checked that just putting it back fixes the problem.

Now this flag should *not* have any effect. From the ghostscript manpage:
Quote:
-dSAFER
Disables the "deletefile" and "renamefile" operators and the
ability to open files in any mode other than read-only. This
strongly recommended for spoolers, conversion scripts or other
sensitive environments where a badly written or malicious
PostScript program code must be prevented from changing impor‐
tant files.

I don't see anything remotely related to our problem here.

May be it's a bug from the last ubuntu ghostscript?
Code:
poliahu:i0 $ gs --version
8.61
poliahu:i0 $

I'll look further into that. In the meantime, I believe you should be able to fix the bug by editing i0/graph.i (in /usr/lib/yorick/i0 in the ubuntu package) and replacing (line 334):
Code:
if (is_void(EPSGS_CMD)) EPSGS_CMD= "gs -q -dNOPAUSE -dBATCH";

by
Code:
if (is_void(EPSGS_CMD)) EPSGS_CMD= "gs -q -dNOPAUSE -sSAFER -dBATCH";


PS: note that the "epsi" command works fine in 2.1.05, and it's also producing eps files (well, epsi, I'm not sure what's the difference). Anyway, something else is that I find that the BB determination within yorick is not very good. If you put axis titltes, it will almost invariably miscalculate the BB. My solution is to go for hcps, and then just ps2epsi the resulting ps file. ps2epsi, in my experience, does a good job determining the best BB. I guess this is the same as using the yorick's epsi....


Fri Feb 22, 2008 7:28 am
Profile WWW
Yorick Master

Joined: Sun Sep 26, 2004 10:33 am
Posts: 150
Location: Australia
Post 
Sylvestre,

ok, I reverted to the initial ubuntu ghostscript (7.10 release) and it's the same thing, so it does not seem to be a ghostcript regression (at least not since october 2007), but it might still be a ghostscript bug.

well, anyway. I guess the debian and ubuntu ghostscript are safe with "-dSAFER", so I will patch graph.i and will release an updated yorick on the maumae ubuntu repos.

By the way: This was also causing problems for the jpeg and png commands (problem now fixed), so thanks for pointing that bug.


Fri Feb 22, 2008 7:50 am
Profile WWW

Joined: Mon Feb 18, 2008 9:41 am
Posts: 9
Post 
Hello Fran├žois

Thank you for this quick fix. It works.
By the way, I am using Gutsi.
And the "pdf" function was also affected, but it is working ok now.

Sylvestre


Fri Feb 22, 2008 9:07 am
Profile WWW
Yorick Master

Joined: Sun Sep 26, 2004 10:33 am
Posts: 150
Location: Australia
Post 
I have checked on fedora8, and the stock eps on yorick 2.1.05 works fine (i.e. it does not crop the boundingbox). So this seems to be a bug of the ubuntu ghostscript (gutsy and also hardy -that's what I am running at the moment- and perhaps also debian). I would need to investigate more to file a bug that is documented enough, and right now I don't really have the time. If anyone wants to volunteer...


Sat Feb 23, 2008 11:20 am
Profile WWW
Yorick Master

Joined: Tue Mar 07, 2006 10:31 pm
Posts: 125
Location: Meudon, France
Post 
Hi,

The Debian package (2.1.05-2) is affected too. I'll upload a corrected package soon.

Note that mere users can set EPSGS_CMD wherever they want (e.g. custom.i), they don't need to fiddle with i0/graph.i.

Finally, the buggy eps files contain the entire information, it's only the bounding box which is affected. You can view the entire plot in gv by manually selecting letter paper instead of BBox. Such files can be fixed using e.g. psfixbb.

T.


Last edited by thibaut on Mon Mar 03, 2008 2:39 am, edited 1 time in total.



Thu Feb 28, 2008 4:52 am
Profile WWW
Yorick Master

Joined: Mon Nov 22, 2004 9:43 am
Posts: 354
Location: Livermore, CA, USA
Post 
Uh oh. I don't know what to do here. I had to remove the -dSAFER to work around a ghostscript bug that prevented the bbox pseudo-output device from working when -dSAFER was present. This bug occurred on a variety of different operating systems, presumably depending on precisely which version of ghostscript was in use. The symptom in taht case was that, with the -dSAFER flag, the bbox device produced output not interpretable as a postscript comment (an error message), which completely breaks the .eps file yorick is trying to build.

Now you tell me that there is another version of ghostscript for which bbox simply gives a different result with -dSAFER than without -dSAFER! That means we're dead, since there isn't any way to figure out whether it works or not!

The purpose of -dSAFER is to prevent malicious code in a postscript file from being executed by the ghostscript interpreter. However, the only postscript code I am passing to ghostscript was in fact generated by yorick itself, so I know that it contains no malicious code (unlike when I run, say, pstoeps on a random postscript file I downloaded from the Web). Therefore it cannot be necessary to use -dSAFER in this case. Therefore the workaround for the original bug -- removing -dSAFER -- is actually more correct than the original which had -dSAFER, and I was happy to get rid of it.

In my opinion, therefore, according to the ghostscript documentation, it is more correct to not use -dSAFER for this application than to use it.

So, what you have to do is to file a bug against the Debian/Ubuntu ghostscript package. The fact that you are getting different output for the bbox device with and without -dSAFER is surely proof of the bug. You will need to provide the smallest postscript file that demonstrates the problem. Preferably, this would NOT be a yorick-generated file. The best case would be if you can find one of the many postscript files distributed with ghostscript itself which triggers this bug (unfortunately most of them don't produce any output, but I think some are documentation files).

In the meantime, the correct way to handle this Debian-specific problem is as a patch to the Debian package with a new Debian version number.

Please do follow up reporting the ghostscript bug. You should mark it serious, to try to get at least the Debian ghostscript maintainer to pay attention.


Fri Feb 29, 2008 7:52 pm
Profile
Yorick Master

Joined: Tue Mar 07, 2006 10:31 pm
Posts: 125
Location: Meudon, France
Post 
munro wrote:
So, what you have to do is to file a bug against the Debian/Ubuntu ghostscript package. The fact that you are getting different output for the bbox device with and without -dSAFER is surely proof of the bug. You will need to provide the smallest postscript file that demonstrates the problem. Preferably, this would NOT be a yorick-generated file. The best case would be if you can find one of the many postscript files distributed with ghostscript itself which triggers this bug (unfortunately most of them don't produce any output, but I think some are documentation files).


OK, I'll do that. It would help if you could list the other versions of ghostscript in which there is no bug and those that require not using -dSAFER.

Regards, Thibaut.


Mon Mar 03, 2008 2:42 am
Profile WWW
Yorick Master

Joined: Mon Nov 22, 2004 9:43 am
Posts: 354
Location: Livermore, CA, USA
Post 
I finally got back to this. I reported a bug (#230893) against the Ubuntu 8.04 ghostscript package. My analysis of the problem reduced it to the following postscript file, which I call gsbug0.ps:
Code:
%!PS-Adobe-3.0
/GistPrimitives 128 dict def
GistPrimitives begin
/GPT {
  currentfile 4 string readhexstring pop { } forall
  exch 8 bitshift or 3 1 roll exch 8 bitshift or exch
} bind def
/D {
  newpath { GPT moveto GPT lineto stroke } repeat
} bind def
end
GistPrimitives begin
/PG save def
0.05 0.05 scale
40 setlinewidth
21 D
0d38331f0d3833fb193d331f193d33fb2542331f254233fb0fa0331f0fa033ab1ba4331f
1ba433ab1207331f120733ab1e0c331f1e0c33ab146e331f146e33ab2073331f207333ab
16d6331f16d633ab22db331f22db33ab0e6c331f0e6c336f10d3331f10d3336f133b331f
133b336f15a2331f15a2336f1809331f1809336f1a71331f1a71336f1cd8331f1cd8336f
1f40331f1f40336f21a7331f21a7336f240e331f240e336f
21 D
254d1b0b26291b0b254d271026292710254d331426293314254d1d7225d91d72254d2977
25d92977254d1fd925d91fd9254d2bde25d92bde254d224125d92241254d2e4625d92e46
254d24a825d924a8254d30ad25d930ad254d1c3e259d1c3e254d1ea6259d1ea6254d210d
259d210d254d2374259d2374254d25dc259d25dc254d2843259d2843254d2aab259d2aab
254d2d12259d2d12254d2f79259d2f79254d31e1259d31e1
PG restore
showpage
end


This file works correctly in some versions of ghostscript with or without -dSAFER, but here is what happens with version 7.07 on a Redhat Enterprise 3 machine:
Code:
/home/munro$ gs gsbug0.ps
GNU Ghostscript 7.07 (2003-05-17)
...
home/munro$ gs -q -dNOPAUSE -dBATCH -sDEVICE=bbox gsbug0.ps
%BoundingBox: 168 345 489 666
%%HiResBoundingBox: 168.200010 345.158005 488.450024 665.350011
/home/munro$ gs -q -dNOPAUSE -dSAFER -dBATCH -sDEVICE=bbox gsbug0.ps
Unrecoverable error: configurationerror in setpagedevice
Operand stack:
    true  --nostringval--


Here is what happens with version 8.61, which I think is the same problem in the rest of this discussion:
Code:
perish[3] gs gsbug0.ps
GPL Ghostscript 8.61 (2007-11-21)
...
/home/munro$ gs -q -dNOPAUSE -dBATCH -sDEVICE=bbox gsbug0.ps
%BoundingBox: 0 0 0 0
%%HiResBoundingBox: 0.000000 0.000000 0.000000 0.000000
/home/munro$ gs -q -dNOPAUSE -dSAFER -dBATCH -sDEVICE=bbox gsbug0.ps
%BoundingBox: 168 345 489 666
%%HiResBoundingBox: 168.200010 345.158005 488.450024 665.350011


Obviously, I can put a switch in the eps, pdf, png, and jpeg functions which either adds or removes -dSAFER. Since the 7.07 bug produces no bounding box at all, rather than an incorrect one, I could toggle the command to omit the -dSAFER for that case and retry the gs command. That might be a reasonable workaround. I can't think of anything else that doesn't require the user to analyze the problem and suggest which one is correct...


Fri May 16, 2008 6:40 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.