pdf2dsc error: invalidaccess --.locksafe--

pdf2dsc error: invalidaccess --.locksafe--

这是我在 AUCTeX 的 preview-latex 中遇到的问题。但是我认为问题应该是由ghostscript引起的,尤其是pdf2dsc工具。

在shell环境下执行的命令

pdf2dsc input.pdf output.dsc

(其中 input.pdf 由 pdflatex 成功生成)将生成空的 output.dsc 和以下错误消息,这会破坏预览命令链,

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

手册页和 google 搜索提供的关于此 "locksafe" 错误消息的信息很少,所以我想知道你们是否有办法修复它。

谢谢。

编辑 输入文件是通过编译以下最小 tex 文件生成的

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

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

pdf 版本 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

我怀疑几乎任何 pdf 输入(例如由 latex -> dvipdf 生成)都会产生相同的错误。我在 ~/Deskop/input 路径中执行此操作。

我也使用建议的命令

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

它确实成功地生成了一个 out.dsc 文件。下一步生成的png图

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

很模糊。

反正我自定义了AUCTeX变量,从dsc到png的最后一步不行,这里是输出

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

编辑

我向 Bugzilla 提交了错误报告。

同时,升级到 ghostscript 9.20(最新)和 AUCTeX 11.89(最新)确实解决了这个问题。

感谢@KenS。

好吧,简单的答案是没有人真的能够帮助使用 7 年前的 Ghostscript 版本,也没有看到输入文件。

错误很简单,在执行“.locksafe”运算符(这是一个非标准的 Ghostscript 扩展,出于 Linux 用户安全考虑而提供)时,程序试图对对象进行不允许的访问.

pdf2dsc PostScript 程序(比较复杂)不直接执行 .locksafe 运算符。它确实调用了 .setsafe,而 .setsafe 调用了 .locksafe,所以这可能是导致问题的路径。

但是,我相信您知道,调试一个软件非常需要我们 运行 在相同条件下运行该软件,以便查看它采用的路径。由于您没有提供原始输入文件,我不能那样做。我也不打算尝试调试旧版本。

老实说,如果您想要 DSC 兼容的 PostScript,最好使用当前版本的 Ghostscript 和 ps2write 设备。

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