Bug 687984

Summary: ps2pdf13 aborts with Error: /dictfull in --image--
Product: Ghostscript Reporter: keinbiervorvier <keinbiervorvier>
Component: PDF WriterAssignee: Stefan Kemper <stefan.kemper>
Status: NOTIFIED FIXED    
Severity: normal CC: igor.melichev
Priority: P2    
Version: master   
Hardware: PC   
OS: Linux   
URL: http://xxx.lanl.gov/ftp/exports/f1.eps
Customer: Word Size: ---

Description keinbiervorvier 2005-03-15 11:41:25 UTC
current cvs HEAD fails on 

$ ps2pdf13 f1.eps

with "Error: /dictfull in --image--"

the figure can be found at http://xxx.lanl.gov/ftp/exports/f1.eps

This started with the changes documented at
http://ghostscript.com/pipermail/gs-cvs/2005-February/005223.html

gs8.51 cvs co prior 2/16/05 generates good pdf from this figure.

more precisely reverting 3 files from current HEAD to earlier revisions,
namely
gdevpdfj.c 1.36
gdevpdfg.h 1.39
gdevpdfi.c 1.60

makes the problem go away. Hope this helps.

Cheers
T.
Comment 1 keinbiervorvier 2005-03-18 11:06:51 UTC
Meanwhile I have come across many more postscript figures which trigger this
problem, see http://xxx.lanl.gov/ftp/exports/dictfull.tar.gz for a selection.

All of these figures have a common Creator string:

%%Creator: Tk Canvas Widget

Cheers
T.
Comment 2 Alex Cherepanov 2005-03-28 05:51:39 UTC
dictfull (= -2) cannot happen in Level 2 PostScript.
Most likely the ERRC (= -2) stream exception get propagated to the interpreter
level.
Comment 3 keinbiervorvier 2005-04-17 21:58:04 UTC
still applies to current cvs head 04/17/05

this affects a lot of figures from the commonly used Tk Canvas Widget for a
lot of authors submitting to http://arXiv.org/

changing 

# cvs diff src/gdevpdfj.c
Index: src/gdevpdfj.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevpdfj.c,v
retrieving revision 1.43
diff -r1.43 gdevpdfj.c
409c409
<       if (piw->binary[0].strm->procs.process == s_DCTE_template.process) {
---
>       if (!(piw->binary[0].strm->procs.process == s_DCTE_template.process)) {

makes this problem go away

T.
Comment 4 Stefan Kemper 2005-04-18 08:25:45 UTC
Igor, 
Please review my patch.

The problem file uses png with a miss-specified height vs data, 
so we are handling a garbage in case.

(gdb) p piw->height
$1 = 1842

(gdb) p data_h
$2 = 1841

Either the streams should all handle this or non of them should.
In the mean time this patch fixes the problem.



Index: gdevpdfj.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevpdfj.c,v
retrieving revision 1.43
diff -u -r1.43 gdevpdfj.c
--- gdevpdfj.c	4 Apr 2005 20:28:27 -0000	1.43
+++ gdevpdfj.c	18 Apr 2005 15:19:42 -0000
@@ -26,6 +26,7 @@
 #include "gxcspace.h"
 #include "gsiparm4.h"
 #include "gdevpsds.h"
+#include "spngpx.h"
 
 #define CHECK(expr)\
   BEGIN if ((code = (expr)) < 0) return code; END
@@ -406,8 +407,9 @@
 			int width, int bits_per_pixel)
 {
     if (data_h != piw->height) {
-	if (piw->binary[0].strm->procs.process == s_DCTE_template.process) {
-	    /* 	Since DCTE can't safely close with incomplete data,
+	if (piw->binary[0].strm->procs.process == s_DCTE_template.process || 
+	    piw->binary[0].strm->procs.process == s_PNGPE_template.process ) {
+	    /* 	Since DCTE and PNGPE can't safely close with incomplete data,
 		we add stub data to complete the stream.
 	    */
 	    int bytes_per_line = (width * bits_per_pixel + 7) / 8;
Comment 5 Igor Melichev 2005-04-18 12:53:50 UTC
Stefan,

Your patch looks good.
Please copmmit if it doesn't contradict to the code freeze state (comply with 
Ray or Raph).
Comment 6 Stefan Kemper 2005-04-18 17:30:35 UTC
Commited Post gs 8.51