Ghostscript segmentation fault on PDF using -dFirstPage and -dLastPage
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GS-GPL |
Fix Released
|
Medium
|
|||
ghostscript (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Trusty |
Fix Released
|
Undecided
|
Marc Deslauriers | ||
Xenial |
Fix Released
|
Undecided
|
Marc Deslauriers | ||
Bionic |
Fix Released
|
Undecided
|
Marc Deslauriers | ||
Cosmic |
Fix Released
|
Undecided
|
Marc Deslauriers | ||
Disco |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
In order to convert a PDF file in PNG I use the command:
» convert "myfile.pdf[0]" test.png
Which gives this error:
convert-im6.q16: FailedToExecute
convert-im6.q16: no images defined `test.png' @ error/convert.
So I tried using ghostscript directly:
» ghostscript -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=
Which gives an error:
GPL Ghostscript 9.26 (2018-11-20)
Copyright (C) 2018 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
[1] 10954 segmentation fault (core dumped) ghostscript -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=
If I omit -dFirstPage=1 -dLastPage=1 it works properly:
» ghostscript -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=
GPL Ghostscript 9.26 (2018-11-20)
Copyright (C) 2018 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 2.
Page 1
Page 2
Please note that it also affects imagemagick convert command and PHP readimage command. I have confirmed the bug on Ubuntu 16.04 too.
The recent ghostscript 9.26 version is definitely guilty.
ProblemType: Bug
DistroRelease: Ubuntu 18.10
Package: ghostscript 9.26~dfsg+
ProcVersionSign
Uname: Linux 4.18.0-11-generic x86_64
NonfreeKernelMo
ApportVersion: 2.20.10-0ubuntu13.1
Architecture: amd64
CurrentDesktop: GNOME
Date: Tue Dec 4 12:59:59 2018
InstallationDate: Installed on 2018-06-28 (158 days ago)
InstallationMedia: Ubuntu 18.04 LTS "Bionic Beaver" - Release amd64 (20180426)
SourcePackage: ghostscript
UpgradeStatus: Upgraded to cosmic on 2018-10-20 (44 days ago)
Changed in gs-gpl: | |
importance: | Unknown → Medium |
status: | Unknown → New |
Changed in gs-gpl: | |
status: | New → Invalid |
Changed in gs-gpl: | |
importance: | Unknown → Medium |
status: | Unknown → Fix Released |
summary: |
- Ghostscript segmentation fault onb PDF using -dFirstPage and -dLastPage + Ghostscript segmentation fault on PDF using -dFirstPage and -dLastPage |
Created attachment 16469
PDF which causes segfault in 9.26
We use ImageMagick to extract a the first page of a PDF as a thumbnail and recently started getting exceptions with some PDFs. Traced it to the call that ImageMagick was making:
gs -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap= 500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlpha Bits=4 '-r72x72' -dLastPage=1 -sOutputFile=1.png -f Bloomfire- Security_ and_Redundancy. pdf
When this is run with GS version 9.25, the thumbnail is extracted with no error.
When this is run with GS version 9.26, I see "Segmentation fault: 11"
I've attached a file that causes there error. Observed on both OSX and Ubuntu Linux.
Here is the output from running the same command with -dDEBUG:
START 0 1455888 160729 1310728 29572 true 587 3 <0>
END PROCS 0 1504736 208805 1330928 35516 true 709 3 <0>
gs_std_e.ps 0 1524936 219150 1330928 38012 true 717 3 <0>
gs_il1_e.ps 0 1524936 225026 1330928 38012 true 718 3 <0>
END FONTDIR/ENCS 0 1524936 225302 1330928 38012 true 720 3 <0>
END DEVS 0 1601672 291074 1330928 38012 true 724 3 <0>
END STATD 0 1601672 305936 1330928 40908 true 729 3 <0>
END GS_FONTS 0 1662272 362977 1330928 40908 true 777 3 <0>
END BASIC COLOR 0 1662272 370569 1330928 40908 true 797 3 <0>
END IMAGE 0 1682472 383205 1330928 40908 true 802 3 <0>
gs_btokn.ps 0 1682472 390509 1330928 40908 true 806 3 <1>
gs_dps1.ps 0 1702672 397919 1330928 40908 true 808 3 <1>
gs_dps2.ps 0 1731320 419098 1330928 40908 true 809 3 <1>
gs_agl.ps 0 2465232 1119600 1330928 40908 true 811 3 <1>
gs_type1.ps 0 2465232 1126479 1330928 41186 true 819 3 <1>
gs_lev2.ps 0 2554480 1192135 1436088 146788 true 825 3 <1>
BEGIN RESOURCES 0 2554480 1194793 1436088 146788 true 825 4 <2>
END CATEGORY 0 2554480 1198912 1436088 147084 true 826 5 <2>
END GENERIC 0 2564516 1219750 1436088 147084 true 828 4 <2>
END FIXED 0 2584716 1237312 1436088 147084 true 828 4 <2>
END MISC 0 2604916 1252528 1436088 147084 true 828 4 <2>
END ENCODING 0 2734596 1382958 1436088 150722 true 828 4 <2>
gs_resmp.ps 10 2774996 1412399 1436088 152568 true 832 3 <2>
gs_res.ps 10 2774996 1410261 1436088 152568 true 832 3 <1>
gs_typ42.ps 10 2774996 1411595 1436088 152568 true 835 3 <1>
gs_cidfn.ps 10 2815396 1446804 1436088 152568 true 843 3 <1>
gs_cidcm.ps 10 2835596 1472845 1436088 152568 true 843 3 <1>
gs_fntem.ps 10 2884444 1520727 1436088 152568 true 845 3 <1>
gs_cidtt.ps 10 2904644 1540784 1436088 152568 true 845 3 <1>
gs_cidfm.ps 10 2924844 1554924 1436088 152568 true 845 3 <1>
gs_cmap.ps 10 2945044 1574218 1436088 152568 true 850 3 <1>
gs_setpd.ps 10 2965244 1599534 1436088 152568 true 850 3 <1>
gs_fapi.ps 10 3005644 1632658 1436088 152568 true 848 3 <1>
gs_typ32.ps 10 3005644 1635417 1436088 152568 true 846 3 <1>
gs_frsd.ps 10 3005644 1638227 1436088 152568 true 846 3 <1>
gs_ll3.ps 10 3167244 1792468 1436088 152816 true 847 3 <1>
gs_icc.ps 10 3167244 1798386 1436088 152816 true 848 3 <1>
gs_mex_e.ps 10 3187444 1804404 1436088 152816 true 848 3 <1>
gs_mro_e.ps 10 3187444 1805591 1436088 152816 true 848 3 <1>
gs_pdf_e.ps 10 3187444 1806824 1436088 152816 true 848 3 <1>
gs_wan_e.ps 10 3187444 1808074 1436088 1...