auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recent preview-latex (or latex?) is again incompatible with ghostscr


From: Chris Liddell
Subject: Re: Recent preview-latex (or latex?) is again incompatible with ghostscript
Date: Tue, 25 May 2021 18:05:36 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1

Hi,

On 25/05/2021 14:50, Ikumi Keita wrote:
> Dear Ghostscript developers,
> 
> It seems that recent preview-latex is again incompatible with
> Ghostscript. We'd appreciate if you could take a look at the problem and
> hopefully provide us a fix.
> 
> In most cases, the prescription you devised for us before works well.
> However, it doesn't work for particular case by some reason unknown to
> us.
> 
> The sequence which ended up with Ghostscript error is like this:
> ----------------------------------------------------------------------
> /usr/local/bin/rungs -sOutputFile\=mwe.prv/tmpMjSoK9/pr1-1.png -q 
> -dDELAYSAFER -dNOPAUSE -DNOPLATFONTS -dPrinted -dTextAlphaBits\=4 
> -dGraphicsAlphaBits\=4 -sDEVICE\=png16m -r94.1897x94.1727 -dDELAYBIND
> GS>systemdict /.addcontrolpath known {/PermitFileReading (mwe.pdf) 
> .addcontrolpath
> /PermitFileReading (mwe.prv/tmpMjSoK9/preview.dsc) .addcontrolpath} if 
> {<</PermitFileReading[(mwe.pdf)(mwe.prv/tmpMjSoK9/preview.dsc)]>> 
> setuserparams .locksafe} stopped pop {DELAYSAFER{.setsafe}if}stopped 
> pop/.preview-BP currentpagedevice/BeginPage get dup null eq{pop{pop}bind}if 
> def<</BeginPage{currentpagedevice/PageSize get dup 0 get 1 ne exch 1 get 1 ne 
> or{.preview-BP gsave 1 1 0.878431 setrgbcolor clippath fill grestore 
> }{pop}ifelse}bind/PageSize[1 1]>>setpagedevice/preview-do{/.preview-ST[count 
> 4 roll save]def dup length 0 eq{pop}{setpagedevice}{ifelse 
> exec}stopped{handleerror quit}if .preview-ST aload pop restore}bind def  
> (mwe.prv/tmpMjSoK9/preview.dsc)(r)file /.preview-ST 1 index def dup 0 
> setfileposition 413()/SubFileDecode filter cvx exec .preview-ST
> GS>dup dup 413 setfileposition 54()/SubFileDecode filter cvx<<>>preview-do
>    **** Error reading a content stream. The page may be incomplete.
>                Output may be incorrect.
> GS<1>
> ----------------------------------------------------------------------
> The pdf file and dsc file are attached below. What is a bit strange to
> me is that the original LaTeX file[1] didn't give error but only a small
> defect of black blob in the generated png file a year ago. So I suspect
> that the change introduced in LaTeX core between TeX Live 2019 and TeX
> Live 2020 affects the contents of the generated pdf file so that
> Ghostscript falls into error rather than a mere defect, because both gs
> 9.52 and 9.54 give the same error here.
> 
> [1] 
> https://tex.stackexchange.com/questions/534438/tikz-and-auctex-different-results/536029
> 
> We'd appreciate if you could confirm the problem and find a way to deal
> with this problem.

Your command uses "-dDELAYBIND" but I cannot see anywhere in the above
that your code calls the ".bindnow" operation.

I am, frankly, stunned this ever works at all, since a considerable
amount of the code (especially the PDF interpter code) relies on the
behaviour of properly "bound" procedures to work as intended.

If you do something like:

/usr/local/bin/rungs -sOutputFile\=mwe.prv/tmpMjSoK9/pr1-1.png -q
-dDELAYSAFER -dNOPAUSE -DNOPLATFONTS -dPrinted -dTextAlphaBits\=4
-dGraphicsAlphaBits\=4 -sDEVICE\=png16m -r94.1897x94.1727 -dDELAYBIND
GS>systemdict /.addcontrolpath known {/PermitFileReading (mwe.pdf)
.addcontrolpath
/PermitFileReading (mwe.prv/tmpMjSoK9/preview.dsc) .addcontrolpath} if
{<</PermitFileReading[(mwe.pdf)(mwe.prv/tmpMjSoK9/preview.dsc)]>>
setuserparams .locksafe} stopped pop {DELAYSAFER{.setsafe}if}stopped pop
{DELAYBIND{.bindnow}if} stopped pop/.preview-BP
currentpagedevice/BeginPage get dup null eq{pop{pop}bind}if
def<</BeginPage{currentpagedevice/PageSize get dup 0 get 1 ne exch 1 get
1 ne or{.preview-BP gsave 1 1 0.878431 setrgbcolor clippath fill
grestore }{pop}ifelse}bind/PageSize[1
1]>>setpagedevice/preview-do{/.preview-ST[count 4 roll save]def dup
length 0 eq{pop}{setpagedevice}{ifelse exec}stopped{handleerror quit}if
.preview-ST aload pop restore}bind def
(mwe.prv/tmpMjSoK9/preview.dsc)(r)file /.preview-ST 1 index def dup 0
setfileposition 413()/SubFileDecode filter cvx exec .preview-ST
GS>dup dup 413 setfileposition 54()/SubFileDecode filter cvx<<>>preview-do

(Note the addition of the "{DELAYBIND{.bindnow}if} stopped pop" after
the similar thing for DELAYSAFER).

At any rate, with DELAYBIND, .bindnow *really* needs to be called early.
For example, I would not be confident of using currentpagedevice or
setpagedevice before calling .bindnow.

Note that I can't try *exactly* your code above because, for me, at
least, those file offsets do not work (with either Unix or DOS line
endings).

The actual cause of the error you see is because, when you use
DELAYBIND, the effect it has to replace "bind" with a procedure that
stores other procedures to bind in an array. When .bindnow is called, it
rattles through that array, binding all the procedures stored in it, it
then disposes of that array, and returns the "real" behaviour of the
bind operator.

That array is approximately twice the size required for all our
initialisation code.

If DELAYBIND is not matched with a .bindnow call the DELAYBIND
definition of bind will remain in place and, eventually, that array will
be exhausted, and you get the error you see.

Whilst I *think* adding the .bindnow call will resolve your issue, I
would *strongly* urge you (maybe not immediately, but at some point) to
review why you have DELAYBIND in there. From the example you posted,
there is no reason for it, and it has security, performance and
behaviour implications - especially if not used properly.

If you could give the above suggestion a try, and let me know if you
still get an issue.

Regards,

Chris




reply via email to

[Prev in Thread] Current Thread [Next in Thread]