Bug 695881 - Ghostscript compiler segfaults on some PDF files
Summary: Ghostscript compiler segfaults on some PDF files
Status: RESOLVED DUPLICATE of bug 695862
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PS Interpreter (show other bugs)
Version: 9.15
Hardware: PC Linux
: P4 normal
Assignee: Ken Sharp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-23 02:32 UTC by Sergey Malkin
Modified: 2015-03-23 08:47 UTC (History)
3 users (show)

See Also:
Customer:
Word Size: ---


Attachments
Strace output (137.72 KB, text/plain)
2015-03-23 02:32 UTC, Sergey Malkin
Details
Problem PDF file (159.00 KB, application/pdf)
2015-03-23 02:33 UTC, Sergey Malkin
Details
Stack trace from gdb (16.51 KB, text/plain)
2015-03-23 03:02 UTC, Sergey Malkin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Malkin 2015-03-23 02:32:23 UTC
Created attachment 11534 [details]
Strace output

Some pdf files generated by matplotlib can not be rasterized by gsc.

gsc -q ./fs_components_func.pdf
[1]    2031 segmentation fault (core dumped)  gsc -q ./fs_components_func.pdf

gsc --version
9.15

I use Arch Linux x86_64 and the latest gs from the extra repository. The only patch applied by the maintainers forces the usage of system zlib.
Comment 1 Sergey Malkin 2015-03-23 02:33:48 UTC
Created attachment 11535 [details]
Problem PDF file
Comment 2 Ken Sharp 2015-03-23 02:39:46 UTC
Ghostscript is an interpreter, not a compiler....
Comment 3 Sergey Malkin 2015-03-23 02:46:30 UTC
gsc is used by Scribus to generate previews and rasterize documents with encapsulated pdf files. Previews for some of my files were not working in Scribus, investigation led me to this bug.
Comment 4 Ken Sharp 2015-03-23 02:52:58 UTC
I've tried this on 32 and 64-bit Windows and 32-bit Linux and am unable to reproduce a problem either with the 9.15 release or with current code. I'll ask one of my colleagues to try 64-bit Linux shortly as I don't currently have access to a 64-bit Linux.

I'm slightly puzzled by your use of 'gsc' as, to the best of my knowledge which is admittedly imperfect on Linux, we don't create a 'gsc' binary on Linux, its called 'gs'. However this may be a quirk of the distribution or something.

Until I can get someone to run a 64-bit comparison my suggestion would be to get the current Ghostscript source (or at least the released 9.15 source), build that, and test again.

The fact that its using a system zlib could easily be the problem. I'd also be a little surprised if zlib was the only system shared library, if they've decided to use one shared library I would expect that all of them would be shared.

You might also try using valgrind or running a debug executable under gdb. I'm afraid the output of strace is not at all helpful.
Comment 5 Ken Sharp 2015-03-23 02:54:13 UTC
Oh, and I would not set -q while trying to debug a problem, if Ghostscript is trying to tell you something, you probably want to see it, not hide it.
Comment 6 Sergey Malkin 2015-03-23 03:02:03 UTC
Created attachment 11536 [details]
Stack trace from gdb
Comment 7 Sergey Malkin 2015-03-23 03:03:14 UTC
I recompiled the same version with debug symbols and run it in GDB. I hope it is more informative.
Comment 8 Ken Sharp 2015-03-23 03:09:43 UTC
This 'looks like' a bug which has already been fixed. Its exposed by a change in the pthread library. Fixed in commit 444e0bf9c43bae0261660e6318ba0e514c18d41e (though I'd pull the latest source myself).

The fix will be in the 9.16 release which is currently in its second release candidate so you can wait for that, or use any of the other suggested workarounds in comment #19 on bug 695862:

http://bugs.ghostscript.com/show_bug.cgi?id=695862

*** This bug has been marked as a duplicate of bug 695862 ***
Comment 9 jsmeix 2015-03-23 04:08:31 UTC
Only an addendum FYI:

(In reply to Ken Sharp from comment #4)
> I'm slightly puzzled by your use of 'gsc' as, to the best of my knowledge
> which is admittedly imperfect on Linux, we don't create a 'gsc' binary on
> Linux, its called 'gs'. However this may be a quirk of the distribution or
> something.

On Linux plain "make ; make install" creates the "gs" binary
but "make so ; make soinstall" creates additionally a "gsc" binary
(plus a "gsx" binary).
As far as I can tell the difference between the "gs" binary
and the "gsc" binary is that "gs" has "libgs" compiled-in
while "gsc" is dynamically linked with "libgs".
Comment 10 Chris Liddell (chrisl) 2015-03-23 05:37:43 UTC
(In reply to Ken Sharp from comment #8)
> This 'looks like' a bug which has already been fixed. Its exposed by a
> change in the pthread library. Fixed in commit
> 444e0bf9c43bae0261660e6318ba0e514c18d41e (though I'd pull the latest source
> myself).
> 
> The fix will be in the 9.16 release which is currently in its second release
> candidate so you can wait for that, or use any of the other suggested
> workarounds in comment #19 on bug 695862:
> 
> http://bugs.ghostscript.com/show_bug.cgi?id=695862
> 
> *** This bug has been marked as a duplicate of bug 695862 ***

It is almost certainly that bug - it seems a change in the glibc/pthreads implementation has exposed the problem, so people are seeing it as distros roll out the update.
Comment 11 Sergey Malkin 2015-03-23 08:38:02 UTC
I tried patching makefile as was suggested here:
http://bugs.ghostscript.com/show_bug.cgi?id=695862#c19
It works for me now. The same problem indeed.
Comment 12 Ken Sharp 2015-03-23 08:47:16 UTC
(In reply to Sergey Malkin from comment #11)
> I tried patching makefile as was suggested here:
> http://bugs.ghostscript.com/show_bug.cgi?id=695862#c19
> It works for me now. The same problem indeed.

That's good to know, thanks for updating us!