pdf2dsc error: invalidaccess --.locksafe--

511 views Asked by At

This is a problem I encountered in preview-latex from AUCTeX. However I believe the problem should be caused by ghostscript, especially the pdf2dsc tool.

The command executed in shell environment

pdf2dsc input.pdf output.dsc

(where the input.pdf was generated successfully by pdflatex) will generate an empty output.dsc and the following error message, which breaks the preview command chain,

Error: /invalidaccess in --.locksafe--
Operand stack:
   true   --nostringval--   --dict:1152/1684(ro)(G)--   getenv   --nostringval--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1862   1   3   %oparray_pop   1861   1   3   %oparray_pop   1845   1   3   %oparray_pop   1739   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   1870   0   3   %oparray_pop   1869   0   3   %oparray_pop   --nostringval--
Dictionary stack:
   --dict:1152/1684(ro)(G)--   --dict:0/20(G)--   --dict:72/200(L)--
Current allocation mode is local
Current file position is 2063
GPL Ghostscript 8.70: Unrecoverable error, exit code 1
Error: /invalidaccess in --.locksafe--
Operand stack:
   true   --nostringval--   --dict:1152/1684(ro)(G)--   getenv   --nostringval--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1862   1   3   %oparray_pop   1861   1   3   %oparray_pop   1845   1   3   %oparray_pop   1739   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   1870   0   3   %oparray_pop   1869   0   3   %oparray_pop   --nostringval--
Dictionary stack:
   --dict:1152/1684(ro)(G)--   --dict:0/20(G)--   --dict:72/200(L)--
Current allocation mode is local
Current file position is 2063
GPL Ghostscript 8.70: Unrecoverable error, exit code 1

The man page and google search give very little information about this "locksafe" error message, so I wander if you guys have a way to fix it.

Thanks.

EDIT The input file was generated by compiling the following minimal tex file

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}

\begin{equation}
1 + 1 = 2
\end{equation}
\end{document}

by pdf version 3.14159265-2.6-1.40.15.

pdfTeX 3.14159265-2.6-1.40.15 (TeX Live 2014)
kpathsea version 6.2.0
Copyright 2014 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Compiled with libpng 1.6.10; using libpng 1.6.10
Compiled with zlib 1.2.8; using zlib 1.2.8
Compiled with xpdf version 3.03

I suspected that virtually any pdf input(for example generated by latex -> dvipdf ) will produce the same error. I'm doing this in the ~/Deskop/input path.

I also use the suggested command

gs -sDEVICE=ps2write -o out.dsc input.pdf

and it does produce an out.dsc file successfully. The png figure produced in the next step

gs -sDEVICE=png16m -o out.png out.dsc 

is quite blurred.

Anyway, I customize the AUCTeX variable, and the last step from dsc to png doesn't work, here is the output

Preview-LaTeX exited as expected with code 1 at Sun Jan  8 12:14:19
Running `Preview-PDF2DSC' with ``gs -sDEVICE=ps2write -o _region_.prv/tmp19812cJl/preview.dsc _region_.pdf''
GPL Ghostscript 8.70 (2009-07-31)
Copyright (C) 2009 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1

Preview-PDF2DSC finished at Sun Jan  8 12:14:19
Running `Preview-Ghostscript' with ``gs -dOutputFile\=\(_region_.prv/tmp19812cJl/pr1-\%d.png\) -q -dNOSAFER -dNOPAUSE -DNOPLATFONTS -dPrinted -dTextAlphaBits\=4 -dGraphicsAlphaBits\=4 -sDEVICE\=png16m -r200.255x200.074''
Ghostscript filter: Args out of range: [(1 102368)], 1

EDIT

I filed a bug report to Bugzilla.

In the meantime, upgrading to ghostscript 9.20(lastest) and AUCTeX 11.89(lastest) does solve the problem.

Thanks @KenS.

1

There are 1 answers

4
KenS On BEST ANSWER

Well, the simple answer is that nobody is really going to be able to help with a 7 year old version of Ghostscript, nor without seeing the input file.

The error is simple, while executing the '.locksafe' operator (which is a non-standard Ghostscript extension, provided because of Linux users security concerns), the program attempted a disallowed access to an object.

The pdf2dsc PostScript program (which is moderately complex) does not execute the .locksafe operator directly. It does call .setsafe, and .setsafe calls .locksafe, so its possible that's the route causing a problem.

However, as I'm sure you are aware, debugging a piece of software pretty much requires that we run the software under the same conditions, in order to see what paths it takes. Since you haven't supplied the original input file, I can't do that. I'm also not going to try and debug an old version either.

To be honest, if you want DSC-compliant PostScript, you would be much better to use the current version of Ghostscript and the ps2write device instead.

gs -sDEVICE=ps2write -o out.dsc input.pdf