Bug 695787 - Ghostscript runaway memory consumption during font search
Summary: Ghostscript runaway memory consumption during font search
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Font API (show other bugs)
Version: 9.10
Hardware: PC Linux
: P4 normal
Assignee: Chris Liddell (chrisl)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-16 02:16 UTC by LionelB
Modified: 2015-02-04 01:12 UTC (History)
2 users (show)

See Also:
Customer:
Word Size: ---


Attachments
fontlog (21.21 KB, text/plain)
2015-02-01 14:12 UTC, LionelB
Details
Log of problematic gs command (see comment) (162.93 KB, text/plain)
2015-02-01 15:11 UTC, LionelB
Details
List of installed fonts (18.62 KB, text/plain)
2015-02-02 00:22 UTC, LionelB
Details
Log of problematic gs command (3.38 MB, text/plain)
2015-02-02 00:51 UTC, LionelB
Details
Log of problematic gs command after uninstallation of Padauk fonts (3.37 MB, text/plain)
2015-02-02 00:54 UTC, LionelB
Details

Note You need to log in before you can comment on or make changes to this bug.
Description LionelB 2015-01-16 02:16:25 UTC
System: Linux Mint 17 (Qiana), Cinnamon 64-bit, kernel 3.13.0-24-generic #47-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux

When Ghostscript searches for a specified font, if that font is not found in the Fontmap file, memory consumption shoots up, the system starts swapping and hangs.

Tested on system (see above) with ~ 2GB memory.

A simple way to reproduce, is to use the following procedure to attempt to display a font:

1) Invoke ghostscript on 'prfont.ps'

$ gs /usr/share/ghostscript/9.10/lib/prfont.ps
GPL Ghostscript 9.10 (2013-08-30)
Copyright (C) 2013 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading NimbusRomNo9L-Regu font from /usr/share/fonts/type1/gsfonts/n021003l.pfb... 3896292 2355421 3853784 2540955 1 done.
GS>

2) At Ghostscript prompt, specify a random fontname - which we know does not exist - to 'DoFont':

GS>/Somefont DoFont
Can't find (or can't open) font file /usr/share/ghostscript/9.10/Resource/Font/Somefont.
Can't find (or can't open) font file Somefont.
Querying operating system for font files...

At vthis point memory usage maxes out, system swaps and hangs.

I expected Ghostscript to conclude the font search (without exhausating system resources!) and to report failure to locate the specified font.

This problem always occurs, and affects any other program which invokes ghostscript and triggers a font search.
Comment 1 Ken Sharp 2015-01-16 02:19:59 UTC
The first thing you should do is try current code, the current release is 9.15.
Comment 2 Ken Sharp 2015-01-16 02:28:16 UTC
I tried this with comparatively old code, nearly the same age as the 9.15 release (22nd September 2014) using the described procedure on a Fedora Linux (kernel is 2.6.35.14).

The described error does not occur for me.

So I suggest that you try the 9.15 release. If that continues to fail I suggest you download the source and build that, as distributions are known to make alterations to the Ghostscript source code and whatever distro you are using may have broken something.
Comment 3 Chris Liddell (chrisl) 2015-01-16 02:30:34 UTC
This doesn't happen for me, using 9.10 on Ubuntu (as packaged by Ubuntu). I get:

GPL Ghostscript 9.10 (2013-08-30)
Copyright (C) 2013 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading NimbusRomNo9L-Regu font from /usr/share/fonts/type1/gsfonts/n021003l.pfb... 3896292 2355421 3853784 2540955 1 done.
GS>/Somefont DoFont
Can't find (or can't open) font file /usr/share/ghostscript/9.10/Resource/Font/Somefont.
Can't find (or can't open) font file Somefont.
Querying operating system for font files...
Can't find (or can't open) font file /usr/share/ghostscript/9.10/Resource/Font/Somefont.
Can't find (or can't open) font file Somefont.
Didn't find this font on the system!
Substituting font Courier for Somefont.
Loading NimbusMonL-Regu font from /usr/share/fonts/type1/gsfonts/n022003l.pfb... 4029892 2552560 6760280 3111865 1 done.
>>showpage, press <return> to continue<<


Takes maybe 4-5 seconds.
Comment 4 Ken Sharp 2015-01-16 02:31:58 UTC
Note; Ghostscript will substitute the missing font with the defined substitute font, it won't report any errors. Eg:

[ken@Fedora-64-VM debugbin]$ ./gs ../lib/prfont.ps
GPL Ghostscript GIT PRERELEASE 9.16 (2014-09-22)
Copyright (C) 2014 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading NimbusRomNo9L-Regu font from %rom%Resource/Font/NimbusRomNo9L-Regu... 3995440 2438187 2816184 1518268 1 done.
GS>/SillyFOnt DoFont
Can't find (or can't open) font file %rom%Resource/Font/SillyFOnt.
Can't find (or can't open) font file SillyFOnt.
Querying operating system for font files...
Can't find (or can't open) font file %rom%Resource/Font/SillyFOnt.
Can't find (or can't open) font file SillyFOnt.
Didn't find this font on the system!
Substituting font Courier for SillyFOnt.
Loading NimbusMonL-Regu font from /usr/share/fonts/default/Type1/n022003l.pfb... 4054840 2617883 4112912 2796413 1 done.
>>showpage, press <return> to continue<<

If your build is non-standard you'll need to tell us how it differs in order to reproduce the problem (if it still exists)
Comment 5 Chris Liddell (chrisl) 2015-01-16 05:34:03 UTC
I've installed Linux Mint 17 x64 (same version listed above) in a VM, and neither the fresh install nor the fully updated one show a problem running the test described in the Description above.

There must be something broken, odd or strange about the configuration to cause it for the OP.
Comment 6 James Cloos 2015-01-16 09:18:40 UTC
Have you installed extra fonts where fontconfig can find them?

If there are lots of fonts, libfontconfig can use more memory, especially if fc-cache hasn’t been run since said fonts were installed, if any of the extra fonts are particularly large or if any of the fonts are malformed.

(Anyone testing this should ensure that every font provided by the distribution is installed, just in case one of them is involved.)
Comment 7 Chris Liddell (chrisl) 2015-01-19 03:34:07 UTC
(In reply to James Cloos from comment #6)
> Have you installed extra fonts where fontconfig can find them?
> 
> If there are lots of fonts, libfontconfig can use more memory, especially if
> fc-cache hasn’t been run since said fonts were installed, if any of the
> extra fonts are particularly large or if any of the fonts are malformed.
> 
> (Anyone testing this should ensure that every font provided by the
> distribution is installed, just in case one of them is involved.)

I am not inclined to contaminate my system with vast numbers of extra fonts (Ubuntu's repos have a *huge* number of font packages), on the off chance there's a problem that isn't actually a Ghostscript issue.

I *am* willing to investigate the problem *if* the OP gives enough information to reproduce it which, following the steps in the description, is simply not the case.
Comment 8 LionelB 2015-02-01 10:58:23 UTC
Apologies for the delay - I do not get to work on this system very frequently.

Firstly, the system configuration is out-of-the-box Linux Mint 17 with all current updates. My ghostscript installation is not a special build, and was installed from the standard repositories

9.10~dfsg-0ubuntu10 (trusty)
9.10~dfsg-0ubuntu10.2 (trusty-updates)

$ gs --help

GPL Ghostscript 9.10 (2013-08-30)
Copyright (C) 2013 Artifex Software, Inc.  All rights reserved.
Usage: gs [switches] [file1.ps file2.ps ...]
Most frequently used switches: (you can use # in place of =)
 -dNOPAUSE           no pause after page   | -q       `quiet', fewer messages
 -g<width>x<height>  page size in pixels   | -r<res>  pixels/inch resolution
 -sDEVICE=<devname>  select device         | -dBATCH  exit after last file
 -sOutputFile=<file> select output file: - for stdout, |command for pipe,
                                         embed %d or %ld for page #
Input formats: PostScript PostScriptLevel1 PostScriptLevel2 PostScriptLevel3 PDF
Default output device: x11alpha
Available devices:
   <long list of drivers>
Search path:
   /usr/share/ghostscript/9.10/Resource/Init :
   /usr/share/ghostscript/9.10/lib :
   /usr/share/ghostscript/9.10/Resource/Font :
   /usr/share/ghostscript/fonts : /var/lib/ghostscript/fonts :
   /usr/share/cups/fonts : /usr/share/ghostscript/fonts :
   /usr/local/lib/ghostscript/fonts : /usr/share/fonts
Ghostscript is also using fontconfig to search for font files
For more information, see /usr/share/doc/ghostscript/Use.htm.
Please report bugs to bugs.ghostscript.com.

The problem persists with this version. Note that it uses fontconfig to search for font files.

Here's what I did:

Firstly I downloaded ghostview 9.15 Linux x86 (64 bit) pre-compiled from the Ghostscript site, and ran it as before

$ /opt/ghostscript-9.15-linux-x86_64/gs-915-linux_x86_64 /usr/share/ghostscript/9.10/lib/prfont.ps
GPL Ghostscript 9.15 (2014-09-22)
Copyright (C) 2014 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading NimbusRomNo9L-Regu font from %rom%Resource/Font/NimbusRomNo9L-Regu... 4122492 2625663 2772304 1474295 1 done.
GS>/Somefont DoFont
Can't find (or can't open) font file %rom%Resource/Font/Somefont.
Can't find (or can't open) font file Somefont.
Querying operating system for font files...
Didn't find this font on the system!
Substituting font Courier for Somefont.
Loading NimbusMonL-Regu font from %rom%Resource/Font/NimbusMonL-Regu... 4139436 2698081 2792496 1503639 1 done.
%%BoundingBox: 23 55 576 769
%%HiResBoundingBox: 23.975999 55.421998 575.171982 768.311977
>>showpage, press <return> to continue<<

So the problem does /not/ occur with this version.

$ /opt/ghostscript-9.15-linux-x86_64/gs-915-linux_x86_64 --help
GPL Ghostscript 9.15 (2014-09-22)
Copyright (C) 2014 Artifex Software, Inc.  All rights reserved.
Usage: gs [switches] [file1.ps file2.ps ...]
Most frequently used switches: (you can use # in place of =)
 -dNOPAUSE           no pause after page   | -q       `quiet', fewer messages
 -g<width>x<height>  page size in pixels   | -r<res>  pixels/inch resolution
 -sDEVICE=<devname>  select device         | -dBATCH  exit after last file
 -sOutputFile=<file> select output file: - for stdout, |command for pipe,
                                         embed %d or %ld for page #
Input formats: PostScript PostScriptLevel1 PostScriptLevel2 PostScriptLevel3 PDF
Default output device: bbox
Available devices:
    <long list of drivers>
Search path:
   %rom%Resource/Init/ : %rom%lib/ :
   /usr/local/share/ghostscript/9.15/Resource/Init :
   /usr/local/share/ghostscript/9.15/lib :
   /usr/local/share/ghostscript/9.15/Resource/Font :
   /usr/local/share/ghostscript/fonts :
   /usr/local/share/fonts/default/ghostscript :
   /usr/local/share/fonts/default/Type1 :
   /usr/local/share/fonts/default/TrueType : /usr/lib/DPS/outline/base :
   /usr/openwin/lib/X11/fonts/Type1 : /usr/openwin/lib/X11/fonts/TrueType
Initialization files are compiled into the executable.
For more information, see /usr/local/share/ghostscript/9.15/doc/Use.htm.
Please report bugs to bugs.ghostscript.com.

So the pre-compiled 9.15 version does /not/ use fontconfig.

Next I downloaded and compiled the 9.15 source (with no non-default configure flags except --with-gs=gs915)

$ gs915 --help
GPL Ghostscript 9.15 (2014-09-22)
Copyright (C) 2014 Artifex Software, Inc.  All rights reserved.
Usage: gs [switches] [file1.ps file2.ps ...]
Most frequently used switches: (you can use # in place of =)
 -dNOPAUSE           no pause after page   | -q       `quiet', fewer messages
 -g<width>x<height>  page size in pixels   | -r<res>  pixels/inch resolution
 -sDEVICE=<devname>  select device         | -dBATCH  exit after last file
 -sOutputFile=<file> select output file: - for stdout, |command for pipe,
                                         embed %d or %ld for page #
Input formats: PostScript PostScriptLevel1 PostScriptLevel2 PostScriptLevel3 PDF
Default output device: x11alpha
Available devices:
    <long list of drivers>
Search path:
   %rom%Resource/Init/ : %rom%lib/ :
   /usr/local/share/ghostscript/9.15/Resource/Init :
   /usr/local/share/ghostscript/9.15/lib :
   /usr/local/share/ghostscript/9.15/Resource/Font :
   /usr/local/share/ghostscript/fonts :
   /usr/local/share/fonts/default/ghostscript :
   /usr/local/share/fonts/default/Type1 :
   /usr/local/share/fonts/default/TrueType : /usr/lib/DPS/outline/base :
   /usr/openwin/lib/X11/fonts/Type1 : /usr/openwin/lib/X11/fonts/TrueType
Ghostscript is also using fontconfig to search for font files
Initialization files are compiled into the executable.
For more information, see /usr/local/share/ghostscript/9.15/doc/Use.htm.
Please report bugs to bugs.ghostscript.com.

Again the problem occurs (memory maxes out, system hangs). And again this version uses fontconfig.

I tried rebuilding the font cache with

$ fc-cache -rfv

This did /not/ solve the problem.

I am not sure how to debug this further, or what further information might be useful to assist in pinpointing the source of the problem.
Comment 9 Chris Liddell (chrisl) 2015-02-01 11:53:10 UTC
I tested both a fresh install, and then allowed it to update, and tested again. Neither showed the problem you describe.

I'll try again, but I see no reason why the results should be different next time.

In fact, I can see no way this can happen without a truly *massive* number of extra fonts installed on the system.

Is there any way you could try this on different hardware?


In the interim, you can disable using fontconfig by using the "-dNONATIVEFONTMAP" command line parameter. If you are using Ghostscript as a subprocess (for example, through ImageMagick) you can use the "GS_OPTIONS" environment variable:

export GS_OPTIONS=-dNONATIVEFONTMAP
Comment 10 Chris Liddell (chrisl) 2015-02-01 13:21:23 UTC
Brand new Linux Mint 17 (Cinnamon) x64 install, running the command in the Description, and it works just fine, takes maybe a second or two to scan the fonts available on the system.

So, again, I'm not sure where to go from here......
Comment 11 Hin-Tak Leung 2015-02-01 13:30:37 UTC
You could try with -dDEBUG:

time gs -dDEBUG -dNOPAUSE -dBATCH /usr/share/ghostscript/9.10/lib/prfont.ps >& /tmp/fontlog

This finishes on my system in about 2s:
real	0m2.025s
user	0m1.627s
sys	0m0.245s

and please attach /tmp/fontlog - it doesn't say the name of the font files, but will say the names of type faces. This at least tell if you have any unusual fonts on your system.
Comment 12 Hin-Tak Leung 2015-02-01 13:36:04 UTC
On my system,

$ grep findname /tmp/fontlog | wc -l
1611

I don't think yours would be much larger than this. I don't cuurently have *all* the fonts for fedora, but I did in an older system, and it was only about 2300, I think.
Comment 13 LionelB 2015-02-01 14:12:52 UTC
Created attachment 11438 [details]
fontlog
Comment 14 Hin-Tak Leung 2015-02-01 14:32:25 UTC
(In reply to LionelB from comment #13)
> Created attachment 11438 [details]
> fontlog

That's useless - it finds /usr/share/fonts/type1/gsfonts/n021003l.pfb as Times-Roman and finishes. That couldn't have taken long nor much memory.

Can you actually try something that would take a while (as you said) and let it finish and capture with -dDEBUG -dNOPAUSE -dBATCH ?
Comment 15 LionelB 2015-02-01 15:11:36 UTC
Created attachment 11439 [details]
Log of problematic gs command (see comment)

$ time echo "/Somefont DoFont" | gs -dDEBUG -dNOPAUSE -dBATCH /usr/share/ghostscript/9.10/lib/prfont.ps - >& /tmp/problog

real	6m28.101s
user	0m6.860s
sys	0m9.710s

problog attached.

During execution, memory usage maxed out, system started swapping and UI froze.
Comment 16 LionelB 2015-02-01 15:19:12 UTC
(In reply to LionelB from comment #15)
> Created attachment 11439 [details]
> Log of problematic gs command (see comment)
> 
> $ time echo "/Somefont DoFont" | gs -dDEBUG -dNOPAUSE -dBATCH
> /usr/share/ghostscript/9.10/lib/prfont.ps - >& /tmp/problog
> 
> real	6m28.101s
> user	0m6.860s
> sys	0m9.710s
> 
> problog attached.
> 
> During execution, memory usage maxed out, system started swapping and UI
> froze.

Are these weird...?

$ grep 'findname: 6 = (\\' problog 
findname: 6 = (\341\200\225\341\200\255\341\200\220\341\200\261\341\200\254\341\200\200\341\200\272-Regular)
findname: 6 = (\341\200\225\341\200\255\341\200\220\341\200\261\341\200\254\341\200\200\341\200\272-\341\200\205\341\200\254\341\200\234\341\200\257\341\200\266\341\200\270\341\200\231\341\200\262)
findname: 6 = (\341\200\225\341\200\255\341\200\220\341\200\261\341\200\254\341\200\200\341\200\272\341\200\205\341\200\254\341\200\241\341\200\257\341\200\225\341\200\272-Regular)
findname: 6 = (\341\200\225\341\200\255\341\200\220\341\200\261\341\200\254\341\200\200\341\200\272\341\200\205\341\200\254\341\200\241\341\200\257\341\200\225\341\200\272-\341\200\205\341\200\254\341\200\234\341\200\257\341\200\266\341\200\270\341\200\231\341\200\262)
Comment 17 Hin-Tak Leung 2015-02-01 15:31:55 UTC
(In reply to LionelB from comment #16)
...
> Are these weird...?
> 
> $ grep 'findname: 6 = (\\' problog 
> findname: 6 =
> (\341\200\225\341\200\255\341\200\220\341\200\261\341\200\254\341\200\200\341
> \200\272-Regular)
> findname: 6 =
> (\341\200\225\341\200\255\341\200\220\341\200\261\341\200\254\341\200\200\341
> \200\272-
> \341\200\205\341\200\254\341\200\234\341\200\257\341\200\266\341\200\270\341\
> 200\231\341\200\262)
> findname: 6 =
> (\341\200\225\341\200\255\341\200\220\341\200\261\341\200\254\341\200\200\341
> \200\272\341\200\205\341\200\254\341\200\241\341\200\257\341\200\225\341\200\
> 272-Regular)
> findname: 6 =
> (\341\200\225\341\200\255\341\200\220\341\200\261\341\200\254\341\200\200\341
> \200\272\341\200\205\341\200\254\341\200\241\341\200\257\341\200\225\341\200\
> 272-
> \341\200\205\341\200\254\341\200\234\341\200\257\341\200\266\341\200\270\341\
> 200\231\341\200\262)

Yes, I was going to comment on that and you beat me to it.
You only have under 500 fonts (compared to my 1600), but I only have about 60% of your fonts. I recognize most of the rest and can probably get hold of them if I want to, but these aren't ones I recognize. I am not too familiar with dpkg, but can you attach the output of:

dpkg -l '*font*'

also? I hope that gives a list of font packages.
Comment 18 Hin-Tak Leung 2015-02-01 15:54:04 UTC
Those seems to be Burmese/Myanmar fonts. Do you actually use those?!
Anyway, I am trying to get hold of them from fedora and see...
Comment 19 Hin-Tak Leung 2015-02-01 16:11:27 UTC
Those 4 fonts seems to be Sil Padauk Book and Sil Padauk, but the ones shipped by fedora have English names (version 2.8). What versions do you have?
They would be named:

Padauk-bold.ttf  Padauk-bookbold.ttf  Padauk-book.ttf  Padauk.ttf

somewhere on your system. I don't know if it is relevant, but I'd suggest upgrading first, just to eliminate them as possibilities. Also, you are in a UTF-8 locale, right?
Comment 20 Hin-Tak Leung 2015-02-01 16:32:44 UTC
One better thing you could try is to re-run the log capture with FC_DEBUG=8 set:

time echo "/Somefont DoFont" | FC_DEBUG=8 gs -dDEBUG -dNOPAUSE -dBATCH /usr/share/ghostscript/9.10/lib/prfont.ps - >& /tmp/problog

That would capture the font file names and location on your system as they are being scanned by fontconfig.
Comment 21 LionelB 2015-02-02 00:22:41 UTC
Created attachment 11440 [details]
List of installed fonts

Output by

dpkg -l '*font*' > fontlist
Comment 22 LionelB 2015-02-02 00:51:01 UTC
Created attachment 11441 [details]
Log of problematic gs command

$ time echo "/Somefont DoFont" | FC_DEBUG=8 gs -dDEBUG -dNOPAUSE -dBATCH /usr/share/ghostscript/9.10/lib/prfont.ps - >& /tmp/problogd

real	6m13.259s
user	0m7.308s
sys	0m10.339s

Just to confirm: system very recently upgraded. Also 

$locale
LANG=en_GB.UTF-8
LANGUAGE=
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC=en_GB.UTF-8
LC_TIME=en_GB.UTF-8
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY=en_GB.UTF-8
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER=en_GB.UTF-8
LC_NAME=en_GB.UTF-8
LC_ADDRESS=en_GB.UTF-8
LC_TELEPHONE=en_GB.UTF-8
LC_MEASUREMENT=en_GB.UTF-8
LC_IDENTIFICATION=en_GB.UTF-8
LC_ALL=

and no, I (almost certainly) don't need the Padauk fonts. I will try uninstalling them.
Comment 23 LionelB 2015-02-02 00:54:08 UTC
Created attachment 11442 [details]
Log of problematic gs command after uninstallation of Padauk fonts

fonts-sil-padauk uninstalled, fc-cache -f run, then

$ time echo "/Somefont DoFont" | FC_DEBUG=8 gs -dDEBUG -dNOPAUSE -dBATCH /usr/share/ghostscript/9.10/lib/prfont.ps - >& /tmp/problogd2

real	5m27.104s
user	0m6.964s
sys	0m9.854s

Problem persists.
Comment 24 Chris Liddell (chrisl) 2015-02-02 01:11:39 UTC
(In reply to LionelB from comment #23)
> Created attachment 11442 [details]
> Log of problematic gs command after uninstallation of Padauk fonts
> 
> fonts-sil-padauk uninstalled, fc-cache -f run, then
> 
> $ time echo "/Somefont DoFont" | FC_DEBUG=8 gs -dDEBUG -dNOPAUSE -dBATCH
> /usr/share/ghostscript/9.10/lib/prfont.ps - >& /tmp/problogd2
> 
> real	5m27.104s
> user	0m6.964s
> sys	0m9.854s
> 
> Problem persists.

So, if I am reading your logging output correctly you have ~716 fonts installed on your system that are visible to fontconfig, whilst my Mint 17 install has only 256 fonts known to fontconfig. So when you said "out-of-box" install, you must have left out at least some details.


When I run the above command, I get:

cliddell@azazel-mintVM ~ $ time echo "/Somefont DoFont" | FC_DEBUG=8 gs -dDEBUG\
 -dNOPAUSE -dBATCH /usr/share/ghostscript/9.10/lib/prfont.ps - >& problog

real	0m4.750s
user	0m1.378s
sys	0m0.711s
Comment 25 LionelB 2015-02-02 01:34:46 UTC
(In reply to Chris Liddell from comment #24)
> (In reply to LionelB from comment #23)
> > Created attachment 11442 [details]
> > Log of problematic gs command after uninstallation of Padauk fonts
> > 
> > fonts-sil-padauk uninstalled, fc-cache -f run, then
> > 
> > $ time echo "/Somefont DoFont" | FC_DEBUG=8 gs -dDEBUG -dNOPAUSE -dBATCH
> > /usr/share/ghostscript/9.10/lib/prfont.ps - >& /tmp/problogd2
> > 
> > real	5m27.104s
> > user	0m6.964s
> > sys	0m9.854s
> > 
> > Problem persists.
> 
> So, if I am reading your logging output correctly you have ~716 fonts
> installed on your system that are visible to fontconfig, whilst my Mint 17
> install has only 256 fonts known to fontconfig. So when you said
> "out-of-box" install, you must have left out at least some details.
> 
> 
> When I run the above command, I get:
> 
> cliddell@azazel-mintVM ~ $ time echo "/Somefont DoFont" | FC_DEBUG=8 gs
> -dDEBUG\
>  -dNOPAUSE -dBATCH /usr/share/ghostscript/9.10/lib/prfont.ps - >& problog
> 
> real	0m4.750s
> user	0m1.378s
> sys	0m0.711s

Sorry - when I said "out-of-box" I meant no strange repositories or funky stuff - anything extra installed (and yes, of course that includes a lot of fonts not in the default desktop install) were installed by apt-get install <package-name> (or synaptic).
Comment 26 Hin-Tak Leung 2015-02-02 01:37:36 UTC
After uninstalling the Padauk fonts, the funny fontname entries are gone, so at least it confirms one thing. I don't know why yours shows funny names while mine don't (supposedly same-ish version).

If you do

grep file: bugs.ghostscript.com/attachment.cgi\?id\=11442\&action\=view   | sort | uniq | cut -f 2 -d \" | xargs ls -Sslr

you get the fonts in increasing size. You may try uninstalling the larger ones?

If your scripting-fu is up for it, with the full list (i.e. removing the "| xargs ..." part), you could try loading each font file individually like this:

echo '(/usr/share/fonts/opentype/cabin/Cabin-BoldItalic.otf) (r) file .findttfontname not {(failed)} if =' | time gs -q -dNOPAUSE -dPATCH >& log

and see if any of them takes a while?
Comment 27 Chris Liddell (chrisl) 2015-02-02 05:18:39 UTC
So, based on my testing here, it seems to be related to the WOFF font you/we have installed on Mint: "fontawesome-webfont.woff".

Now, what's weird is that I have the same font installed on my Ubuntu system, also using gs 9.10, and also using fontconfig, and that font is found by the fontconfig search, but the whole thing completes in around 2 seconds..... Ghostscript just skips over the WOFF because it's unsupported.

The versions of the font are different, which *may* account for the issue.

I have an idea how to solve it, but I need to experiment a little.... I'll update this when I know more.
Comment 28 Chris Liddell (chrisl) 2015-02-04 01:12:25 UTC
Fixed (for me, at least) with this commit:

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

As this is entirely in the Postscript world, you can patch the files in your distribution to try it out.