Bug 691439 - segmentation fault when processes pdf file with CID fonts
Summary: segmentation fault when processes pdf file with CID fonts
Status: RESOLVED WORKSFORME
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: 8.71
Hardware: PC Windows XP
: P4 normal
Assignee: Ken Sharp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-02 14:13 UTC by Jinsong Zhao
Modified: 2010-07-08 12:48 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
pdf can cause pdfwrite corrupt. (5.71 KB, application/pdf)
2010-07-02 14:13 UTC, Jinsong Zhao
Details
another pdf file, with one CID font (5.45 KB, application/pdf)
2010-07-02 14:15 UTC, Jinsong Zhao
Details
Output from the current development version of GS (6.57 KB, application/pdf)
2010-07-07 07:19 UTC, Ken Sharp
Details
Output from the 8.71 release version of Ghostscript (7.03 KB, application/pdf)
2010-07-07 07:20 UTC, Ken Sharp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jinsong Zhao 2010-07-02 14:13:14 UTC
Created attachment 6424 [details]
pdf can cause pdfwrite corrupt.

Hi there,

I have a PDF with CID fonts. I hope to embed all CID fonts using
pdfwrite device from ghostscript. However, when i run the following command (the PDF file is attached):

gswin32c.exe -sDEVICE=pdfwrite -o two_embed.pdf two.pdf

Then following error message appears:

"gswin32c.exe has encountered a problem and needs to close."

It seems a segmentation fault.

However, when I exchange the following two line in the PDF file,
gswin32c.exe give correct result.

/F1001 1 Tf 12.00 0.00 -0.00 12.00 62.40 81.20 Tm <c4e3bac3> Tj
/F1002 1 Tf 12.00 0.00 -0.00 12.00 62.40 119.42 Tm <c4e3bac3> Tj

When the PDF have only one CID font /F1001, it also cannot be processed
by pdfwrite. However, if the /F1001 replace by /F1002 or any other font,
the pdfwrite can process it. For example,

changing
/F1001 1 Tf 12.00 0.00 -0.00 12.00 233.07 81.20 Tm <c4e3bac3> Tj
to
/F1002 1 Tf 12.00 0.00 -0.00 12.00 233.07 81.20 Tm <c4e3bac3> Tj
or
/F1003 1 Tf 12.00 0.00 -0.00 12.00 233.07 81.20 Tm <c4e3bac3> Tj
or
...
However, I don't like to change the font.

All those PDF file could be viewed by Adobe Acorbat Reader, and
gswin32c.exe.

The ghostscript version is 8.71. I have test those PDF files on version 8.70, 8.60, 8.15, all worked well.

I think it is a bug of pdfwrite.

Jinsong
Comment 1 Jinsong Zhao 2010-07-02 14:15:04 UTC
Created attachment 6425 [details]
another pdf file, with one CID font

This pdf file demo the second situation in the previous bug report.
Comment 2 Ken Sharp 2010-07-06 13:19:06 UTC
(In reply to comment #0)

> pdfwrite device from ghostscript. However, when i run the following command
> (the PDF file is attached):
> 
> gswin32c.exe -sDEVICE=pdfwrite -o two_embed.pdf two.pdf
> 
> Then following error message appears:
> 
> "gswin32c.exe has encountered a problem and needs to close."
> 
> It seems a segmentation fault.

As you are aware, the PDF file does not contain any embedded fonts, and the font family referenced from the PDF file (SimSun) is not one of the fonts supplied with Ghostscript.

This suggests that you must have added the font to the Ghostscript installation. Since these are CIDFonts this further implies that you have modified the file gs/Resource/Init/cidfmap. Could you please tell me what changes you have made so that I can attempt to reproduce this problem ?
Comment 3 Jinsong Zhao 2010-07-06 13:52:04 UTC
(In reply to comment #2)
> 
> As you are aware, the PDF file does not contain any embedded fonts, and the
> font family referenced from the PDF file (SimSun) is not one of the fonts
> supplied with Ghostscript.

I know the PDF dones not contain any embedded fonts, the SimSun or any font with regular face are not one of the fonts supplied with Ghsstscritp.

> 
> This suggests that you must have added the font to the Ghostscript
> installation. Since these are CIDFonts this further implies that you have
> modified the file gs/Resource/Init/cidfmap. Could you please tell me what
> changes you have made so that I can attempt to reproduce this problem ?

But I have noted that the font SimSun is included in the cidfmap file at least for the Chinese users. I am just very curious why I exchange the position of two lines, and then Ghostscript will run smoothly. I can supply you a PDF file with the Chinese font available from Adobe Acorbat Reader if you are interested.

Regards,
Jinsong
Comment 4 Ken Sharp 2010-07-06 14:02:08 UTC
(In reply to comment #3)

> > This suggests that you must have added the font to the Ghostscript
> > installation. Since these are CIDFonts this further implies that you have
> > modified the file gs/Resource/Init/cidfmap. Could you please tell me what
> > changes you have made so that I can attempt to reproduce this problem ?
> 
> But I have noted that the font SimSun is included in the cidfmap file at least
> for the Chinese users.

Ghostscript does not include any references to any fonts in the shipped version of cidfmap. It is possible that installers may add to it.


> I am just very curious why I exchange the position of
> two lines, and then Ghostscript will run smoothly.

I have no idea, especially since the version I have here, using a cidfmap modified by me, works perfectly well.


> I can supply you a PDF file
> with the Chinese font available from Adobe Acorbat Reader if you are
> interested.

Thank you but I can make that myself. However please do provide the entry for SimSun from the cidfmap file.
Comment 5 Jinsong Zhao 2010-07-06 17:18:27 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > > This suggests that you must have added the font to the Ghostscript
> > > installation. Since these are CIDFonts this further implies that you have
> > > modified the file gs/Resource/Init/cidfmap. Could you please tell me what
> > > changes you have made so that I can attempt to reproduce this problem ?
> > 
> > But I have noted that the font SimSun is included in the cidfmap file at least
> > for the Chinese users.
> Ghostscript does not include any references to any fonts in the shipped version
> of cidfmap. It is possible that installers may add to it.

Maybe your are right. However, when I installed Ghostscript on my Windows XP home edition (the default codepage is CP936 here), and check the options for CJK ture type fonts, I get a cidfmap whith a SimSun entry included in it.

> > I am just very curious why I exchange the position of
> > two lines, and then Ghostscript will run smoothly.
> I have no idea, especially since the version I have here, using a cidfmap
> modified by me, works perfectly well.
> > I can supply you a PDF file
> > with the Chinese font available from Adobe Acorbat Reader if you are
> > interested.
> Thank you but I can make that myself. However please do provide the entry for
> SimSun from the cidfmap file.

Which version you are using? According to my test, I think it's just a bug in 8.71.

(In reply to comment #4)
> (In reply to comment #3)
> > > This suggests that you must have added the font to the Ghostscript
> > > installation. Since these are CIDFonts this further implies that you have
> > > modified the file gs/Resource/Init/cidfmap. Could you please tell me what
> > > changes you have made so that I can attempt to reproduce this problem ?
> > 
> > But I have noted that the font SimSun is included in the cidfmap file at least
> > for the Chinese users.
> Ghostscript does not include any references to any fonts in the shipped version
> of cidfmap. It is possible that installers may add to it.
> > I am just very curious why I exchange the position of
> > two lines, and then Ghostscript will run smoothly.
> I have no idea, especially since the version I have here, using a cidfmap
> modified by me, works perfectly well.
> > I can supply you a PDF file
> > with the Chinese font available from Adobe Acorbat Reader if you are
> > interested.
> Thank you but I can make that myself. However please do provide the entry for
> SimSun from the cidfmap file.

The entry for SimSun in the cidfmap is:

/SimSun << /FileType /TrueType /SubfontID 0 /CSI [(GB1) 2] /Path (C:/WINDOWS/fonts/simsun.ttc) >> ;

Regards,
Jinsong
Comment 6 Hin-Tak Leung 2010-07-07 02:14:55 UTC
(In reply to comment #4)
> Ghostscript does not include any references to any fonts in the shipped version
> of cidfmap. It is possible that installers may add to it.

That's correct - the official installer written by Russell does the equivalent of:

gswin32c -q -dBATCH -sFONTDIR=c:/windows/fonts \
  -sCIDFMAP=lib/cidfmap lib/mkcidfm.ps

to scan the windows font directory to generate cidfmap, if the user select "Use windows CJK font" during installation.
Comment 7 Ken Sharp 2010-07-07 07:19:41 UTC
Created attachment 6438 [details]
Output from the current development version of GS

(In reply to comment #5)
> Which version you are using? According to my test, I think it's just a bug in
> 8.71.

I am using the current development version, soon to be released.

 
> The entry for SimSun in the cidfmap is:
> 
> /SimSun << /FileType /TrueType /SubfontID 0 /CSI [(GB1) 2] /Path
> (C:/WINDOWS/fonts/simsun.ttc) >> ;

That's the same as I am using, and it works well for me. Can you build a copy of Ghostscript from source ? If so I would suggest you get a copy of the latest source and try it.

However I also tried this on a copy of the 8.71 release and that also worked for me. I'm attaching the two PDF files created by 8.71 and the 8.72 development version.
Comment 8 Ken Sharp 2010-07-07 07:20:36 UTC
Created attachment 6439 [details]
Output from the 8.71 release version of Ghostscript
Comment 9 Jinsong Zhao 2010-07-07 16:22:42 UTC
(In reply to comment #7)
> > 
> > /SimSun << /FileType /TrueType /SubfontID 0 /CSI [(GB1) 2] /Path
> > (C:/WINDOWS/fonts/simsun.ttc) >> ;
> That's the same as I am using, and it works well for me. Can you build a copy
> of Ghostscript from source ? If so I would suggest you get a copy of the latest
> source and try it.

I cannot build a copy of Ghostscript on Windows platform. And I have no Linux now, :-(

> However I also tried this on a copy of the 8.71 release and that also worked
> for me. I'm attaching the two PDF files created by 8.71 and the 8.72
> development version.

Which platform are you using?

Well, it may be just a error on my box....

Thank you very much for your testing!

Regards,
Jinsong
Comment 10 Hin-Tak Leung 2010-07-07 21:36:31 UTC
(In reply to comment #9)
> (In reply to comment #7)
> > of Ghostscript from source ? If so I would suggest you get a copy of the latest
> > source and try it.
> 
> I cannot build a copy of Ghostscript on Windows platform. And I have no Linux
> now, :-(

There are some windows builds of somewhat recent (2 weeks old) dev code under:
http://www.ghostscript.com/~hintak/

This is the older winzipse-based installer:
http://www.ghostscript.com/~hintak/GS872W32-r11356+tt.exe

This is a more recent snapshot with the new nsis-based installer:
http://www.ghostscript.com/~hintak/GS872w32-r11392+tt-nsis.exe

*very important* (1) if you install one, please uninstall before installing the other - *bad things* can happen to your registry if you install one on top of the other. (I hope to block the nsis installer from installing over the winzip installer in the next few weeks.)

These snapshots are provided just for trying out of the new installer functionality so I hope they work and can verify that bugs are fixed in more recent dev builds, but please don't file bugs on problems with them unless you can see the problem from a build you made.
Comment 11 Ken Sharp 2010-07-08 07:12:05 UTC
> > However I also tried this on a copy of the 8.71 release and that also worked
> > for me. I'm attaching the two PDF files created by 8.71 and the 8.72
> > development version.
> 
> Which platform are you using?

Windows Vista and I made a quick try on Fedora just for completeness (using the current source on both) I only tried 8.71 on Windows Vista. Tried both debug and release builds of the HEAD revision on both systems.

 
> Well, it may be just a error on my box....
> 
> Thank you very much for your testing!

Since I can't reproduce this I'm closing as 'WORKSFORME', if you can reproduce the problem using the builds Hin-Tak has posted, then please reopen the bug and detail the steps you took and I will investigate again.
Comment 12 Jinsong Zhao 2010-07-08 12:48:04 UTC
(In reply to comment #10)
> 
> There are some windows builds of somewhat recent (2 weeks old) dev code under:
> http://www.ghostscript.com/~hintak/
> 
> This is the older winzipse-based installer:
> http://www.ghostscript.com/~hintak/GS872W32-r11356+tt.exe
> 
> This is a more recent snapshot with the new nsis-based installer:
> http://www.ghostscript.com/~hintak/GS872w32-r11392+tt-nsis.exe
> 

I have test those Ghostscript, and they all works. Thank you very much!