Bug 691063 - gs segfault error when building lilypond
Summary: gs segfault error when building lilypond
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: 8.64
Hardware: PC Linux
: P4 normal
Assignee: Alex Cherepanov
URL: http://bugzilla.novell.com/show_bug.c...
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-17 02:55 UTC by Dave Plater
Modified: 2011-11-30 15:38 UTC (History)
3 users (show)

See Also:
Customer:
Word Size: ---


Attachments
All files to reproduce the segfault (367.32 KB, application/x-bzip)
2010-01-17 02:57 UTC, Dave Plater
Details
Same files but from a successful build (1.18 MB, application/x-bzip)
2010-01-17 04:35 UTC, Dave Plater
Details
droid fonts (4.12 MB, application/x-tar)
2010-01-17 05:49 UTC, Dave Plater
Details
lilypond fonts (503.79 KB, application/x-gzip)
2010-01-17 05:50 UTC, Dave Plater
Details
otstoy.tar.bz2 -- self-contained sample (1.45 MB, application/octet-stream)
2010-01-30 18:11 UTC, Alex Cherepanov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Plater 2010-01-17 02:55:25 UTC
This a call for help with the above bug which occurs during a lilypond build
frequently if the variable "GS_LIB=/home/davepl/.fonts" is unset and
occasionally if the above variable is set. The file sets to reproduce the bug
are attached to the novell bug as I can't see a way to attach anything here.
The command :-
gs  -dNOSAFER -dEPSCrop -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH -r1200
-sDEVICE=pdfwrite -sOutputFile="./4e/lily-7d242e8d-1.pdf" -c .setpdfwrite -f
"./4e/lily-7d242e8d-1.eps"
gives the result :-
GPL Ghostscript 8.64 (2009-02-03)
Copyright (C) 2009 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file COPYING for details.
Can't handle format 12
Segmentation fault
Comment 1 Dave Plater 2010-01-17 02:57:11 UTC
Created attachment 5876 [details]
All files to reproduce the segfault
Comment 2 Dave Plater 2010-01-17 04:35:20 UTC
Created attachment 5877 [details]
Same files but from a successful build

These files result from a build of lilypond docs with the variable :
 GS_LIB=/home/davepl/.fonts set.
Comment 3 Ken Sharp 2010-01-17 04:37:06 UTC
Difficult to tell what's going on, because the single file in the bzip archive
has no extension, turns out to be a tarball (a .tar would have helped here).

There's > 4.5Mb of log file which is kind of difficult to parse through and well
nigh meaningless to me for most of it. I'm going to assume that the error (seg
fault) noted in the original submission is the problem.

The error also reads 'Cant' handle format 12', this is a warning from the
Ghostscript TrueType interpreter that it is unable to understand format 12 CMAP
subtables. Looking inside the relevant EPS file (lily-7d242e8d-1.eps) I see that
it seems to use several fonts:

/fonts/otf/CenturySchL-Roma.otf
/usr/share/fonts/truetype/DroidSansFallback.ttf
/fonts/otf/emmentaler-20.otf

However none of these fonts are supplied, so I can't be sure which of these is
the issue, nor even if this *is* an issue for certain.

If the original reporter would like to post the fonts as well, I can determine
which font is causing the issue and see why this is causing a segmentation fault
for pdfwrite. Actually supporting format 12 CMAP subtables is (probably) a much
longer term project, probably an enhancement.
Comment 4 Dave Plater 2010-01-17 05:09:38 UTC
The files in the attached tar.bz2 in directory 4e are the files lilypond
attempts conversion on. Hopefully they aren't corrupted on your side, I've just
extracted them to test 8.70 which I have packaged the same as the existing 8.64
 Using the packaged openSUSE gs-8.70 and have just attempted the same command
from cli :-
gs  -dNOSAFER -dEPSCrop -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH -r1200
-sDEVICE=pdfwrite -sOutputFile="./4e/lily-7d242e8d-1.pdf" -c .setpdfwrite -f
"./4e/lily-7d242e8d-1.eps"
And it succeeded with the output :-
GPL Ghostscript 8.70 (2009-07-31)
Copyright (C) 2009 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file COPYING for details.
GPL Ghostscript 8.70: Error: Font Renderer Plugin ( FreeType ) return code = -1
Can't render Font ArialMT with FAPI, will do with native GS renderer.
Can't handle format 12
GPL Ghostscript 8.70: Error: Font Renderer Plugin ( FreeType ) return code = -1
Can't render Font DroidSansFallback with FAPI, will do with native GS renderer.

I'm maintainer of lilypond for openSUSE which is my interest in this problem and
unfortunately not very familiar with the workings of ghostscript. From the
output with gs-8.70 I assume that gs can handle the missing fonts better. What
puzzles me is why the variable "GS_LIB=/home/davepl/.fonts" allows lilypond to
execute the above command without a problem. This happens with gs-8.70 and 8.64.
There is a possible license conflict with gs-8.70 which has delayed the update
for the distro but I will find out next week if it really is a problem. I'm not
a novell employee only an openSUSE community member.
I'll dig into the lilypond build and see if I can find the fonts.
If you search the log for the exact command used above you will find the failure.
Comment 5 Dave Plater 2010-01-17 05:28:29 UTC
Re fonts :-
/fonts/otf/CenturySchL-Roma.otf                  Belongs to lilypond
/fonts/otf/emmentaler-20.otf                     Belongs to lilypond
/usr/share/fonts/truetype/DroidSansFallback.ttf  Found in a separate package
called droid-fonts which I've now added as a build requirement for lilypond.

If it's of any help I can tar.bz2 them and attach them to this bug.
You have already explained half of the problem and if you can explain why the
environment variable makes such a difference, it would be very much appreciated.
Comment 6 Dave Plater 2010-01-17 05:49:21 UTC
Created attachment 5878 [details]
droid fonts
Comment 7 Dave Plater 2010-01-17 05:50:33 UTC
Created attachment 5879 [details]
lilypond fonts
Comment 8 Ray Johnston 2010-01-17 09:23:44 UTC
Note that there have been many segfaults fixed since 8.64 so please re-test
with the HEAD version (or wait a couple of weeks until we have a release
candidate or our release at the beginning of Feb.)
Comment 9 Alex Cherepanov 2010-01-30 18:11:26 UTC
Created attachment 5927 [details]
otstoy.tar.bz2 -- self-contained sample

Please try the attached sample. Decompress the archive to to a current
directory
and run:
gs  -dNOSAFER -dEPSCrop -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH -r1200
-sDEVICE=pdfwrite -sOutputFile=fail.pdf -c .setpdfwrite -f fail.eps

I tried this on several hosts and several versions of Ghostscript but
was unable to reproduce SEGV. Perhaps, it's related to FAPI, which I don't use.

There will be some FAPI improvements in the upcoming release.
Comment 10 Dave Plater 2010-01-31 05:26:55 UTC
Command fails :-
> gs  -dNOSAFER -dEPSCrop -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH -r1200
-sDEVICE=pdfwrite -sOutputFile=fail.pdf -c .setpdfwrite -f fail.eps
GPL Ghostscript 8.70 (2009-07-31)
Copyright (C) 2009 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file COPYING for details.
Can't handle format 12
Decompressed the attachment into a new directory and executed the command.
Comment 11 Ken Sharp 2010-01-31 05:57:01 UTC
Can you be a little more explicit ? When you say 'command fails' what exactly do
you mean ? Do you still get a segmentation fault, or do you get some other
problem? The 'Can't handle format 12' message is not a problem, the file still
converts to PDF even with that warning.

You hadn't mentioned that you were building Ghostscript to use the FreeType font
rendering engine, this changes things quite markedly and invalidates the tests I
ran because I wasn't using the FreeType interface.

As Alex has mentioned the next release will contain some extensive improvements
to the FreeType interface. You can see some of the changes in bug report #690448
which is being used to track the progress of the FreeType interface. There have
already been a significant number of fixes, especially relating to segmentation
faults and errors. I would suggest that you try the latest HEAD revision of the
GS source, or wait until the next scheduled release which is only a week or so away.
Comment 12 Dave Plater 2010-01-31 21:27:01 UTC
There wasn't a segfault but the lilypond build still fails about 10% of the time
after which a rebuild succeeds. I'll build a head version for lilypond to build
against, which should be easy as long as there aren't too many changes and
report back. I have lilypond building against both gs-8.64 and 8.70 ATM and it
rebuilds every time openSUSE Factory changes, about once a week on average.
Just to prevent any future confusion, this is the configure setup for the main
build :-
  ./configure --build=%{buildsys}	\
	    --prefix=%{_prefix}		\
	    --bindir=%{_bindir}		\
	    --mandir=%{_mandir}		\
	    --datadir=%{_datadir}	\
	    --infodir=%{_infodir}	\
	    --libdir=%{_libdir}		\
	    --with-fontpath=%{fonts}	\
	    --with-ijs			\
	    --with-omni			\
	    --with-jbig2dec		\
	    --with-jasper		\
	    --enable-dynamic		\
	    --enable-cups		\
	    --enable-shared		\
	    --with-driversfile=%{S:41}  \
	    --disable-gtk		\
	    --disable-compile-inits	\
	    --with-gnu-ld
Comment 13 Dr. Werner Fink 2010-10-14 10:57:11 UTC
With ghostscript 9.00 the result is not a crash, nevertheless it does
not work:/usr/src/packages/BUILD/lilypond-2.12.3/out/lybook-db> gs -dEPSCrop -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dNOPAUSE -sDEVICE=png16m -sOutputFile="./d6/lily-50e2bfee.png" -r202 "./d6/lily-50e2bfee.eps" -c quit
GPL Ghostscript  9.00 (2010-09-14)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file COPYING for details.
Can't handle format 12
Error: /typecheck in --@0xb6b6f260--
Operand stack:
   1.951   0.0   0.0   uni306B   1.951   0.0   0.0   uni306F   1.951   0.0   0.0   uni308D   1.951   77.7211   -24.8756   --dict:15/17(ro)(L)--   uni3044   uni3044   --nostringval--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1910   1   3   %oparray_pop   1909   1   3   %oparray_pop   --nostringval--   1893   1   3   %oparray_pop   1787   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   3   --nostringval--   %repeat_continue   --nostringval--   %finish_show   --nostringval--   --nostringval--   6   3   15   --nostringval--   (gs_show_enum)   %op_show_continue
Dictionary stack:
   --dict:1177/3371(ro)(G)--   --dict:0/20(G)--   --dict:121/200(L)--
Current allocation mode is local
Last OS error: 2
Current file position is 18904
GPL Ghostscript  9.00: Unrecoverable error, exit code 1
Comment 14 Dr. Werner Fink 2010-10-14 11:10:18 UTC
This piece of code

 /DroidSansFallback 3.61523438 output-scale div selectfont
 1.9510 0.0000 0.0000 /uni306B
 1.9510 0.0000 0.0000 /uni306F
 1.9510 0.0000 0.0000 /uni308D
 1.9510 0.0000 0.0000 /uni3044
 4 print_glyphs
 74.9001 -21.3256 moveto

cause this break.
Comment 15 Alex Cherepanov 2011-11-25 05:15:57 UTC
I cannot reproduce this problem. I've tested gs v. 8.71, 9.00, and the current
development version. Lilypond 2.12.3 can be built with either version of
Ghostscript.

Feel free to reopen this bug of file a new one if there are still
any problems with Ghostscript.
Comment 16 Dave Plater 2011-11-29 17:31:54 UTC
No gs problems for quite a while now, guile has taken gs's place.
Comment 17 Ray Johnston 2011-11-29 17:49:24 UTC
I totally don't understand Dave's comment "guile has taken gs's place."

Unless I'm missing something guile (GNU Ubiquitous Intelligent Language for
Extensions) -- a library designed to help programmers create flexible
applications -- is totally orthogonal to gs.

gs is a specific application that does PCL, XPS, PDF, and PS conversion to
printer formats, image formats, or PS, PDF, PCL, etc.  -- how does guile
replace that ?
Comment 18 Dave Plater 2011-11-30 15:09:48 UTC
(In reply to comment #17)
> I totally don't understand Dave's comment "guile has taken gs's place."
> 
> Unless I'm missing something guile (GNU Ubiquitous Intelligent Language for
> Extensions) -- a library designed to help programmers create flexible
> applications -- is totally orthogonal to gs.
> 
> gs is a specific application that does PCL, XPS, PDF, and PS conversion to
> printer formats, image formats, or PS, PDF, PCL, etc.  -- how does guile
> replace that ?

I apologise for my familiar manner I was in the middle of getting lilypond to build with a 1.8 guile package as it can't use guile 2.x. Ghostscript 9 no longer segfaults at all, it may very rarely fail during the lilypond build if two or more simultaneous instances of gs are used but if only one instance is allowed, the build succeeds every time. This has been the case for quite a while.
Comment 19 Dave Plater 2011-11-30 15:38:43 UTC
AFAIR the gs failure was also aggravated by droid fonts which I removed from my lilypond documentation build and is also no longer recommended by lilypond. If this is of interest.