Bug 696554 - Error: /typecheck in resource status on postscript file
Summary: Error: /typecheck in resource status on postscript file
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: General (show other bugs)
Version: 9.18
Hardware: Macintosh MacOS X
: P4 normal
Assignee: Chris Liddell (chrisl)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-28 12:23 UTC by howarth.mailing.lists
Modified: 2016-01-29 06:45 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
failing postscript file (420.06 KB, application/postscript)
2016-01-28 12:23 UTC, howarth.mailing.lists
Details
output from "export FC_DEBUG=5; gs 206nm_melts_all.ps" (52.56 KB, text/plain)
2016-01-28 13:45 UTC, howarth.mailing.lists
Details
output with modified /sw/share/ghostscript/9.18/Resource/Init/gs_fonts.ps (28.71 KB, text/plain)
2016-01-28 14:26 UTC, howarth.mailing.lists
Details
gs_fonts.ps debugging code added (45.48 KB, application/postscript)
2016-01-28 15:23 UTC, Chris Liddell (chrisl)
Details
output with debug version of gs_fonts.ps (87.02 KB, text/plain)
2016-01-28 15:48 UTC, howarth.mailing.lists
Details

Note You need to log in before you can comment on or make changes to this bug.
Description howarth.mailing.lists 2016-01-28 12:23:59 UTC
Created attachment 12282 [details]
failing postscript file

The attached postscript file fails on ghostscript 9.16 and 9.19 with the error...

GPL Ghostscript 9.18 (2015-10-05)
Copyright (C) 2015 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Querying operating system for font files...
Error: /typecheck in resourcestatus
Operand stack:
   false   ct_StyleDicts   --dict:0/4(L)--   Adobe-Japan1   --dict:0/4(L)--   Serif   HeiseiMin-W3-83pv-RKSJ-H   Font   HeiseiMin-W3-83pv-RKSJ-H   (HeiseiMin-W3-83pv-RKSJ-H)   true   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1977   1   3   %oparray_pop   1976   1   3   %oparray_pop   1960   1   3   %oparray_pop   1852   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   1931   8   8   %oparray_pop
Dictionary stack:
   --dict:1194/1684(ro)(G)--   --dict:0/20(G)--   --dict:84/200(L)--   --dict:54/73(L)--   --dict:2/10(L)--   --dict:39/70(L)--   --dict:0/4(L)--   --dict:0/4(L)--   --dict:17/17(ro)(G)--
Current allocation mode is local
Current file position is 90149
GPL Ghostscript 9.18: Unrecoverable error, exit code 1

whereas Apple's Preview application and Adobe Illustrator CS3 opens it without complaint.
Comment 1 Chris Liddell (chrisl) 2016-01-28 12:48:55 UTC
I don't get any errors with the current code on Ubuntu. I'm guessing it's related to something in one of the font files it's trying to enumerate. Or possibly something that (I'm guessing) fontconfig is returning is not what we expect.

If you are willing/able to do a little legwork (debugging by proxy!), I can give you some things to try to help narrow down where the problem lies.


In the meantime, you might get output if you include the command line option: -dNONATIVEFONTMAP.
Comment 2 howarth.mailing.lists 2016-01-28 13:11:53 UTC
(In reply to Chris Liddell (chrisl) from comment #1)
> I don't get any errors with the current code on Ubuntu. I'm guessing it's
> related to something in one of the font files it's trying to enumerate. Or
> possibly something that (I'm guessing) fontconfig is returning is not what
> we expect.
> 
> If you are willing/able to do a little legwork (debugging by proxy!), I can
> give you some things to try to help narrow down where the problem lies.
> 
> 
> In the meantime, you might get output if you include the command line
> option: -dNONATIVEFONTMAP.

Yes. Appending -dNONATIVEFONTMAP does allow the postscript file to render. However, I am seeing this failure on x86_64 darwin using the ghostscript 9.18 build from the fink project as well as the ghostscript 9.16 build from the MacPorts project. The fink ghostscript build is configured as follows...

	mv zlib zlib_local
	mv libpng libpng_local
	mv jpeg jpeg_local
	mv openjpeg openjpeg_local
	mv tiff tiff_local
	mv freetype freetype_local
	mv jbig2dec jbig2dec_local
	mv lcms2 lcms2_local
	./autogen.sh --prefix=/sw 	--mandir=/sw/share/man \
	--disable-compile-inits \
	--disable-cups \
	--disable-gtk \
	--with-system-libtiff \
 --x-includes=$X11_BASE_DIR/include \
 --x-libraries=$X11_BASE_DIR/lib \
 --with-x
Generating configuration files for ghostscript, please wait....
  running autoconf
running ./configure --prefix=/sw --mandir=/sw/share/man --disable-compile-inits --disable-cups --disable-gtk --with-system-libtiff --x-includes=/opt/X11/include --x-libraries=/opt/X11/lib --with-x
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for a sed that does not truncate output... /sw/bin/sed
checking for ranlib... ranlib
checking for pkg-config... /sw/bin/pkg-config
checking supported compiler flags... 
   -O2
   -Wall
   -Wstrict-prototypes
   -Wundef
   -Wmissing-declarations
   -Wmissing-prototypes
   -Wwrite-strings
   -Wno-strict-aliasing
   -Werror=declaration-after-statement
   -fno-builtin
   -fno-common
   -Werror=return-type

   -gdwarf-2
   -g3
   -O0
 ...done.
checking for big endian... little
checking sse2 support... yes
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking malloc.h usability... no
checking malloc.h presence... no
checking for malloc.h... no
checking for memory.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/times.h usability... yes
checking sys/times.h presence... yes
checking for sys/times.h... yes
checking syslog.h usability... yes
checking syslog.h presence... yes
checking for syslog.h... yes
checking for unistd.h... (cached) yes
checking dirent.h usability... yes
checking dirent.h presence... yes
checking for dirent.h... yes
checking ndir.h usability... no
checking ndir.h presence... no
checking for ndir.h... no
checking sys/dir.h usability... yes
checking sys/dir.h presence... yes
checking for sys/dir.h... yes
checking sys/ndir.h usability... no
checking sys/ndir.h presence... no
checking for sys/ndir.h... no
checking for inttypes.h... (cached) yes
checking sys/window.h usability... no
checking sys/window.h presence... no
checking for sys/window.h... no
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for mode_t... yes
checking for off_t... yes
checking for size_t... yes
checking for struct stat.st_blocks... yes
checking whether time.h and sys/time.h may both be included... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking size of unsigned long int... 8
checking for cos in -lm... yes
checking for pread... yes
checking for pwrite... yes
checking whether pwrite is declared... yes
checking whether pread is declared... yes
checking for pthread_create in -lpthread... yes
checking recursive mutexes.......... checking for iconv_open... no
checking for libiconv_open in -liconv... yes
checking for stringprep in -lidn... yes
checking stringprep.h usability... yes
checking stringprep.h presence... yes
checking for stringprep.h... yes
checking for systempapername in -lpaper... yes
checking paper.h usability... yes
checking paper.h presence... yes
checking for paper.h... yes
checking for fontconfig with pkg-config... yes
checking for dbus with pkg-config... no
checking for dbus_message_iter_get_basic in -ldbus... no
checking for dlopen in -ldl... yes
checking for local freetype library source... checking for local jpeg library source... no
checking for jpeg_set_defaults in -ljpeg... yes
checking jpeglib.h usability... yes
checking jpeglib.h presence... yes
checking for jpeglib.h... yes
checking for jmemsys.h... no
checking for local zlib source... no
checking for deflate in -lz... yes
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking for local png library source... no
checking for png_create_write_struct in -lpng... yes
checking png.h usability... yes
checking png.h presence... yes
checking for png.h... yes
checking for local lcms2 library source... no
checking for system lcms2 library... checking for _cmsCreateMutex in -llcms2... yes
checking lcms2.h usability... yes
checking lcms2.h presence... yes
checking for lcms2.h... yes
checking for libtiff with pkg-config... yes
checking for local ijs library source... yes
checking for local Luratech JBIG2 library source... no
checking for local jbig2dec library source... no
checking for jbig2_page_out in -ljbig2dec... yes
checking for local Luratech JPEG2K library source... no
checking for fseeko... yes
checking whether lrintf is declared... yes
checking for local OpenJPEG library source... no
checking for system OpenJPEG library... yes
checking for X... libraries /opt/X11/lib, headers /opt/X11/include
checking whether -R must be followed by a space... neither works
checking for gethostbyname... yes
checking for connect... yes
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... yes
checking for XOpenDisplay in -lX11... yes
checking for XdbeQueryExtension in -lXext... yes
checking for XtAppCreateShell in -lXt... yes
checking for mkstemp... yes
checking for fopen64... no
checking for fseeko... (cached) yes
checking for mkstemp64... no
checking for setlocale... yes
checking for strerror... yes
checking whether gcc needs -traditional... no
checking for pid_t... yes
checking vfork.h usability... no
checking vfork.h presence... no
checking for vfork.h... no
checking for fork... yes
checking for vfork... yes
checking for working fork... yes
checking for working vfork... (cached) yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking for working memcmp... yes
checking return type of signal handlers... void
checking whether lstat correctly handles trailing slash... no
checking whether stat accepts an empty string... no
checking for vprintf... yes
checking for _doprnt... no
checking for bzero... yes
checking for dup2... yes
checking for floor... yes
checking for gettimeofday... yes
checking for memchr... yes
checking for memmove... yes
checking for memset... yes
checking for mkdir... yes
checking for mkfifo... yes
checking for modf... yes
checking for pow... yes
checking for putenv... yes
checking for rint... yes
checking for setenv... yes
checking for sqrt... yes
checking for strchr... yes
checking for strrchr... yes
checking for strspn... yes
checking for strstr... yes
checking minimum memory pointer alignment... done
checking for sqrtf... yes
checking for strnlen... yes
checking byteswap support... yes
checking for byteswap.h... no

building against FreeType 2.6. The MacPorts ghostscript build uses the command...

DEBUG: Executing command line:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_print_ghostscript/ghostscript/work/ghostscript-9.16" && ./configure --prefix=/opt/local --disable-compile-inits --disable-cups --disable-dbus --disable-gtk --with-x --without-luratech --with-system-libtiff 
checking for gcc... /usr/bin/clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /usr/bin/clang accepts -g... yes
checking for /usr/bin/clang option to accept ISO C89... none needed
checking how to run the C preprocessor... /usr/bin/clang -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for ranlib... ranlib
checking for pkg-config... /opt/local/bin/pkg-config
checking supported compiler flags... 
   -O2
   -Wall
   -Wstrict-prototypes
   -Wundef
   -Wmissing-declarations
   -Wmissing-prototypes
   -Wwrite-strings
   -Wno-strict-aliasing
   -fno-builtin
   -fno-common

   -gdwarf-2
   -g3
   -O0
 ...done.
checking for big endian... little
checking sse2 support... yes
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking malloc.h usability... no
checking malloc.h presence... no
checking for malloc.h... no
checking for memory.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/times.h usability... yes
checking sys/times.h presence... yes
checking for sys/times.h... yes
checking syslog.h usability... yes
checking syslog.h presence... yes
checking for syslog.h... yes
checking for unistd.h... (cached) yes
checking dirent.h usability... yes
checking dirent.h presence... yes
checking for dirent.h... yes
checking ndir.h usability... no
checking ndir.h presence... no
checking for ndir.h... no
checking sys/dir.h usability... yes
checking sys/dir.h presence... yes
checking for sys/dir.h... yes
checking sys/ndir.h usability... no
checking sys/ndir.h presence... no
checking for sys/ndir.h... no
checking for inttypes.h... (cached) yes
checking sys/window.h usability... no
checking sys/window.h presence... no
checking for sys/window.h... no
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for mode_t... yes
checking for off_t... yes
checking for size_t... yes
checking for struct stat.st_blocks... yes
checking whether time.h and sys/time.h may both be included... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking size of unsigned long int... 8
checking for cos in -lm... yes
checking for pread... yes
checking for pwrite... yes
checking whether pwrite is declared... yes
checking whether pread is declared... yes
checking for pthread_create in -lpthread... yes
checking recursive mutexes.......... checking for local trio library source... trio
checking for iconv_open... no
checking for libiconv_open in -liconv... yes
checking for stringprep in -lidn... yes
checking stringprep.h usability... yes
checking stringprep.h presence... yes
checking for stringprep.h... yes
checking for systempapername in -lpaper... yes
checking paper.h usability... yes
checking paper.h presence... yes
checking for paper.h... yes
checking for fontconfig with pkg-config... yes
checking for dlopen in -ldl... yes
checking for local freetype library source... no
checking for system freetype2 >= 2.4.2 with pkg-config... yes
checking for local jpeg library source... no
checking for jpeg_set_defaults in -ljpeg... yes
checking jpeglib.h usability... yes
checking jpeglib.h presence... yes
checking for jpeglib.h... yes
checking for jmemsys.h... no
checking for local zlib source... no
checking for deflate in -lz... yes
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking for local png library source... no
checking for png_create_write_struct in -lpng... yes
checking png.h usability... yes
checking png.h presence... yes
checking for png.h... yes
checking for local lcms2 library source... yes
checking for libtiff with pkg-config... yes
checking for local ijs library source... yes
checking for local jbig2dec library source... no
checking for jbig2_page_out in -ljbig2dec... yes
checking for fseeko... yes
checking whether lrintf is declared... yes
checking for local OpenJPEG library source... yes
checking for memalign... no
checking for X... libraries , headers 
checking for gethostbyname... yes
checking for connect... yes
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... yes
checking for XOpenDisplay in -lX11... yes
checking for XdbeQueryExtension in -lXext... yes
checking for XtAppCreateShell in -lXt... yes
checking for mkstemp... yes
checking for fopen64... no
checking for fseeko... (cached) yes
checking for mkstemp64... no
checking for setlocale... yes
checking for strerror... yes
checking whether /usr/bin/clang needs -traditional... no
checking for pid_t... yes
checking vfork.h usability... no
checking vfork.h presence... no
checking for vfork.h... no
checking for fork... yes
checking for vfork... yes
checking for working fork... yes
checking for working vfork... (cached) yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking for working memcmp... yes
checking return type of signal handlers... void
checking whether lstat correctly handles trailing slash... no
checking whether stat accepts an empty string... no
checking for vprintf... yes
checking for _doprnt... no
checking for bzero... yes
checking for dup2... yes
checking for floor... yes
checking for gettimeofday... yes
checking for memchr... yes
checking for memmove... yes
checking for memset... yes
checking for mkdir... yes
checking for mkfifo... yes
checking for modf... yes
checking for pow... yes
checking for putenv... yes
checking for rint... yes
checking for setenv... yes
checking for sqrt... yes
checking for strchr... yes
checking for strrchr... yes
checking for strspn... yes
checking for strstr... yes
checking for sqrtf... yes
checking for strnlen... yes
checking for floorl... yes
checking for ceill... yes
checking for powl... yes
checking for fmodl... yes
checking for log10l... yes
checking byteswap support... yes
checking for byteswap.h... no

and builds against FreeType 2.6.2. Perhaps this is an issue specific to Xquartz used on darwin?
Comment 3 Chris Liddell (chrisl) 2016-01-28 13:38:25 UTC
(In reply to howarth.mailing.lists from comment #2)
<SNIP> 
> Yes. Appending -dNONATIVEFONTMAP does allow the postscript file to render.
> However, I am seeing this failure on x86_64 darwin using the ghostscript
> 9.18 build from the fink project as well as the ghostscript 9.16 build from
> the MacPorts project. The fink ghostscript build is configured as follows...
> 
<SNIP>> 
> and builds against FreeType 2.6.2. Perhaps this is an issue specific to
> Xquartz used on darwin?

This has nothing to do with Freetype, nor the specific version of X.

What your configure output does show is that both builds are using fontconfig.

Your Postscript file is referencing fonts which are not embedded in the file, nor are they part of the "core" Postscript font set. If available, Ghostscript will call fontconfig to retrieve list of available font files and the names of the fonts in those files (at least as far as fontconfig knows them). Ghostscript will then whittle that list down, excluding font files it cannot use, for whatever reason.

It *looks* like something in either the retrieval of the list, or the whittling process is going wrong, and we need to work out exactly where and why that's happening.
Comment 4 howarth.mailing.lists 2016-01-28 13:45:48 UTC
Created attachment 12283 [details]
output from "export FC_DEBUG=5; gs 206nm_melts_all.ps"
Comment 5 howarth.mailing.lists 2016-01-28 13:47:15 UTC
Does the attached output from "export FC_DEBUG=5; gs 206nm_melts_all.ps" help?
Comment 6 Chris Liddell (chrisl) 2016-01-28 14:14:27 UTC
(In reply to howarth.mailing.lists from comment #5)
> Does the attached output from "export FC_DEBUG=5; gs 206nm_melts_all.ps"
> help?

Sorry, not really.

What I'm going to need is for you to add some code (possibly multiple times) to the Ghostscript Postscript files. Which should be in:
/sw/share/ghostscript/9.18/Resource/Init     (fink)

or

/opt/local/share/ghostscript/9.18/Resource/Init     (MacPorts)

Depending on which of the above listed builds you are using.

Starting with the file: gs_fonts.ps. Open it in a plain text editor, search for the line reading:
% DEBUG { (  found ) print dup print (\n) print flush } if

Below that, temporarily add the following line:
(  found ) print dup == (\n) print flush

And then rerun your test (obviously without the -dNONATIVEFONTMAP option).

Hopefully, you'll get a bunch of lines of output like:
found (DejaVuSerifCondensed-Italic)

If you can paste that output, complete, that *may* give me enough to go on - or it may just hint at where to look next.

Sorry, but debugging Postscript by proxy is a little laborious!
Comment 7 howarth.mailing.lists 2016-01-28 14:26:40 UTC
Created attachment 12284 [details]
output with modified /sw/share/ghostscript/9.18/Resource/Init/gs_fonts.ps
Comment 8 howarth.mailing.lists 2016-01-28 14:29:36 UTC
The results don't seem to add a specific error but only shows that...

  found (BitstreamVeraSansMono-BoldOb)

was the last font before the error...

Error: /typecheck in resourcestatus
Comment 9 howarth.mailing.lists 2016-01-28 14:41:44 UTC
Also tested a ghostscript 9.18 built with FSF gcc 5.3 rather than clang to confirm that the bug isn't related to compiler optimizations. It still fails on darwin.
Comment 10 howarth.mailing.lists 2016-01-28 14:49:16 UTC
Also confirmed that rebuilding fontconfig with FSF gcc 5.3 has no impact on the bug. Note that fink uses fontconfig 2.10.2 and MacPorts fontconfig  2.11.1.
Comment 11 Chris Liddell (chrisl) 2016-01-28 14:51:35 UTC
Before I go further with the debugging stuff, I did a fix a few months ago that I'm wondering if it might be relevant, and is probably worth trying.

So, still in gs_font.ps, again looking for the line:
% DEBUG { (  found ) print dup print (\n) print flush } if

Then two lines above that (or thereabouts) should be:
3 -1 roll pop

If you can replace that with this line:
counttomark 1 add -1 roll pop

And re-run your file.

For a little more context, here's the commit for the fix:
http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=5aa97eed0f
Comment 12 howarth.mailing.lists 2016-01-28 15:10:59 UTC
(In reply to Chris Liddell (chrisl) from comment #11)
> Before I go further with the debugging stuff, I did a fix a few months ago
> that I'm wondering if it might be relevant, and is probably worth trying.
> 
> So, still in gs_font.ps, again looking for the line:
> % DEBUG { (  found ) print dup print (\n) print flush } if
> 
> Then two lines above that (or thereabouts) should be:
> 3 -1 roll pop
> 
> If you can replace that with this line:
> counttomark 1 add -1 roll pop
> 
> And re-run your file.
> 
> For a little more context, here's the commit for the fix:
> http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=5aa97eed0f

That doesn't eliminate the error.
Comment 13 Chris Liddell (chrisl) 2016-01-28 15:23:52 UTC
Created attachment 12285 [details]
gs_fonts.ps debugging code added

Slight change of tack. It's possible the problem is not in this area after all, but I'd like to eliminate it fully.

Here's a gs_fonts.ps with more extensive debugging comments already added. If you backup your existing one, and replace it with this, and run your file (yet) again, and post the results.
Comment 14 howarth.mailing.lists 2016-01-28 15:48:48 UTC
Created attachment 12286 [details]
output with debug version of gs_fonts.ps
Comment 15 Chris Liddell (chrisl) 2016-01-29 04:25:11 UTC
I think this should fix the issue:

http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=471af1e1

If not, please reopen this bug.
Comment 16 howarth.mailing.lists 2016-01-29 04:37:37 UTC
Applying the committed change to /sw/share/ghostscript/9.18/Resource/Init/gs_fonts.ps doesn't eliminate the crash which appears the same as originally reported.
Comment 17 Chris Liddell (chrisl) 2016-01-29 05:01:23 UTC
(In reply to howarth.mailing.lists from comment #16)
> Applying the committed change to
> /sw/share/ghostscript/9.18/Resource/Init/gs_fonts.ps doesn't eliminate the
> crash which appears the same as originally reported.

It fixes it on my mac......

I guess you'll probably need to include the fix from comment 11, replacing:
3 -1 roll pop

with

counttomark 1 add -1 roll pop
Comment 18 howarth.mailing.lists 2016-01-29 05:25:34 UTC
Both fixes are required to eliminate the bug.

diff -uNr ghostscript-9.18.orig/Resource/Init/gs_fonts.ps ghostscript-9.18/Resource/Init/gs_fonts.ps
--- ghostscript-9.18.orig/Resource/Init/gs_fonts.ps     2015-10-05 04:21:11.000000000 -0400
+++ ghostscript-9.18/Resource/Init/gs_fonts.ps  2016-01-29 08:17:32.000000000 -0500
@@ -183,7 +183,7 @@
     } if
     {           % Stack: key file
                 % Protect ourselves against syntax errors here.
-      dup { token } stopped { pop //false exit } if
+      dup { token } stopped { //false exit } if
       not { //false exit } if               % end of file
       dup /eexec eq { pop //false exit } if       % reached eexec section
       dup /Subrs eq { pop //false exit } if       % Subrs without eexec
@@ -410,7 +410,7 @@
             pop
           }
           {
-            3 -1 roll pop
+            counttomark 1 add -1 roll pop
             not { dup 0 get } if  % stack: (newname) [ (name) (path) ]
             % DEBUG { (  found ) print dup print (\n) print flush } if
             % add entry to the fontmap
Comment 19 Chris Liddell (chrisl) 2016-01-29 05:41:33 UTC
Phew, thanks!

Always the danger when cherry picking new fixes into older code.
Comment 20 howarth.mailing.lists 2016-01-29 06:15:05 UTC
(In reply to Chris Liddell (chrisl) from comment #19)
> Phew, thanks!
> 
> Always the danger when cherry picking new fixes into older code.

Any idea what font issue exists on darwin which isn't found on Ubuntu? Is there some problem with the Xquartz fonts which should be reported to them?
Comment 21 Chris Liddell (chrisl) 2016-01-29 06:45:53 UTC
(In reply to howarth.mailing.lists from comment #20)
> (In reply to Chris Liddell (chrisl) from comment #19)
> > Phew, thanks!
> > 
> > Always the danger when cherry picking new fixes into older code.
> 
> Any idea what font issue exists on darwin which isn't found on Ubuntu? Is
> there some problem with the Xquartz fonts which should be reported to them?

It's a dfont file, which Postscript (and thus Ghostscript) does not support.

It's possible we could add a non-standard extension to support dfonts, but a) this stuff is written in Postscript, and it is not really desirable to have platform specific stuff in Postscript, and b) I understood even Apple were shifting away from using dfont files.

So, for now, it's best just to handle the incompatibility gracefully.