Bug 702471

Summary: eps to pdf OK in 9.50, but failed in 9.51 and 9.52
Product: Ghostscript Reporter: Jinsong Zhao <jszhao>
Component: PDF WriterAssignee: Ken Sharp <ken.sharp>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P4    
Version: 9.51   
Hardware: All   
OS: All   
Customer: Word Size: ---
Attachments: the eps that cause problem

Description Jinsong Zhao 2020-06-06 00:38:01 UTC
Created attachment 19309 [details]
the eps that cause problem

When converting my thesis in ps format to pdf using 9.51,

gswin64c -dNOSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -sOutputFile=thesis.pdf thesis.ps 

I encountered the following error message:

Error: /ioerror in --colorimage--
Operand stack:
   175.032   -169.639   175.032   -159.639   229.531   -159.639 229.531   -145.88   288.977   -169.639   288.977   -159.639   229.531 -159.639   229.531   -145.88   131.17   -217.924   121.17   -217.924 121.17   -317.789   151.165   -317.789   218.84   -288.149   228.84 -288.149   288.977   -288.149   288.977   -186.77
Execution stack:
   %interp_exit   .runexec2   --nostringval--   colorimage --nostringval--   2   %stopped_push   --nostringval--   colorimage colorimage   false   1   %stopped_push   1990   1   3   %oparray_pop 1989   1   3   %oparray_pop   1977   1   3   %oparray_pop   1833   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2 --nostringval--   colorimage   --nostringval--   2   %stopped_push --nostringval--   colorimage   1863   39   7   %oparray_pop
Dictionary stack:
   --dict:750/1123(ro)(G)--   --dict:1/20(G)--   --dict:150/200(L)-- --dict:653/675(L)--   --dict:71/200(L)--   --dict:176/300(L)-- --dict:139/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
Current file position is 38698441
GPL Ghostscript 9.51: Unrecoverable error, exit code 1

when i switch to 9.50, error disappeared.

When preparing the minimal work example, I located the problem to a eps file that i attached here. here is how to reproduce the problem:

gswin64c -sDEVICE=pdfwrite -o mwe.pdf mwe.eps

GPL Ghostscript 9.51 (2020-03-12)
Copyright (C) 2020 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Loading P052-Roman font from %rom%Resource/Font/P052-Roman... 5004108 3500015 2184824 869270 2 done.
Error: /ioerror in --colorimage--
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   colorimage   --nostringval--   2   %stopped_push   --nostringval--   colorimage   colorimage   false   1   %stopped_push   1990   1   3   %oparray_pop   1989   1   3   %oparray_pop   1988   1   3   %oparray_pop   colorimage   1977   1   3   %oparray_pop   1833   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   colorimage   --nostringval--   2   %stopped_push   --nostringval--   colorimage   1863   7   5   %oparray_pop
Dictionary stack:
   --dict:738/1123(ro)(G)--   --dict:0/20(G)--   --dict:81/200(L)--   --dict:176/300(L)--   --dict:139/200(L)--
Current allocation mode is local
Last OS error: Permission denied
Current file position is 167031
GPL Ghostscript 9.51: Unrecoverable error, exit code 1 

Tested with 9.52, same error.
Comment 1 Ray Johnston 2020-06-10 06:22:21 UTC
This ioerror is generated in pdf_image_end_image_data (line 1927):
 ecode = psdf_end_binary(&(pie->writer.binary[pie->writer.alt_writer_count]));
returning -12 (ioerror).

This 'clean up' code was not in 9.50 and stems from commit 51aff033.

The 17th 'colorimage' triggers the 'skipping' code at line 375 in psi/zimage.c
which causes the image_cleanup immediately without passing any data.

Even though the original was reported on Windows, it also occurs on linux.

Assigning to Ken, although he may want to pass it along to someone else.
Comment 2 Ken Sharp 2020-06-10 09:18:20 UTC
Fixed in commit a4edd8320a5076bb52d1be7c061910b3b78718e0