Bug 691653

Summary: Regression: /undefined in --run-- with pdfwrite starting with r11667
Product: Ghostscript Reporter: Marcos H. Woehrmann <marcos.woehrmann>
Component: PDF WriterAssignee: Michael Vrhel <michael.vrhel>
Status: RESOLVED FIXED    
Severity: normal CC: christinedelight.top85
Priority: P1    
Version: 0.00   
Hardware: PC   
OS: All   
Customer: Word Size: ---

Description Marcos H. Woehrmann 2010-09-29 19:47:27 UTC
Starting with r11667 the following commands cause an "/undefined in --run--" error:

  ./bin/gs -o test.pdf ./Bug689880.pdf
  ./bin/gs -o test.ppm ./test.pdf
Comment 2 Michael Vrhel 2011-06-11 17:00:52 UTC
Assigning to Ken to review.
Comment 3 Ken Sharp 2012-10-18 09:20:18 UTC
Well this seems to be related to Michael's recoding of the pdf_make_iccbased() routine.

The problem is that we have a type 3 Shading which has a DeviceN colour space with a /Lab alternate. When we come to emit that we end up having to write out the alternate as an ICCBased colour space.

This takes us into pdf_make_iccbased() from pdf_iccbased_color_space(). Now, in pdf_mak_iccbased() at around line 282 of gdevpdfk.c we check the min and max Range values for the space to see if they are between 0 and 1, which they are not in this case, because its an Lab space, they are in fact between 0 and 100.

After the commented line /* We'll have to scale the inputs :-( */ the code tests 'pprange' to see if its 0, which it is, because we pass a NULL in here. This leads to a rangecheck error which is swallowed at some point in the return process, leading to an invalid colour space.

When we come to write out the Shading dictionary this also errors (because the colour space is invalid) and we write a truncated, invalid, Shading dictionary, which is what leads to the PDF error.

Now, by passing in a dummy value for pprange instead of NULL I get a PDF file which 'works' in as much as Acrobat and Ghostscript can both open it and render the result. But this strikes me as more than slightly hacky!

I'm really not sure what, if anything, I should be doing with the returned pprange value, so I'm passing this one back to Michael.
Comment 4 Ken Sharp 2012-10-19 16:41:57 UTC
commit 19f407d322ba43e1aff403f625bd4d2a723f5e65 works around the problem but I'd still like Michael to review this.