Bug 1424752

Summary: ghostscript bug creates high CPU load and hangs
Product: Red Hat Enterprise Linux 7 Reporter: Yogita <ysoni>
Component: ghostscriptAssignee: David Kaspar // Dee'Kej <deekej>
Status: CLOSED ERRATA QA Contact: QE Internationalization Bugs <qe-i18n-bugs>
Severity: high Docs Contact: Jiri Herrmann <jherrman>
Priority: urgent    
Version: 7.3CC: dbodnarc, deekej, dkochuka, jherrman, kdudka, lmanasko, mmatsuya, qe-i18n-bugs, smaitra, ysoni
Target Milestone: rcKeywords: EasyFix, i18n, Patch, Regression, Reproducer, ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: ghostscript-9.07-24.el7 Doc Type: Release Note
Doc Text:
*ghostscript* no longer becomes unresponsive in some situations Under certain circumstances, the *ghostscript* application previously entered an infinite loop, became unresponsive, and caused excessive CPU load. This update fixes the underlying code, which prevents the described problem from occurring.
Story Points: ---
Clone Of:
: 1455084 (view as bug list) Environment:
Last Closed: 2017-08-01 23:03:50 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1395973, 1420851, 1455084    
Attachments:
Description Flags
This is a demo pdf file we have used to test in above command
none
possible fix [from git bisect] kdudka: review+

Description Yogita 2017-02-19 07:31:07 UTC
Created attachment 1255371 [details]
This is a demo pdf file we have used to test in above command

Description of problem:
The latest ghostscript version shipped by Redhat is 9.07.20 contains a bug which under certain circumstances causes "gs" to spin at 100% CPU load until manually killed.

Version-Release number of selected component (if applicable):
Rhel 7.3
Package - ghostscript.9.07.20

How reproducible:
The problem can also be reproduced using ImageMagick command /usr/bin/convert:

Steps to Reproduce:
1. /usr/bin/convert ATK_Broschüre_2017.pdf /tmp/test.gif

Actual results:
1. The command hangs and using top command it can be seen that cpu is utilised 99-100% by "gs"

Expected results:
1 The ATK_Broschüre_2017.pdf should have got converted to test.gif in /tmp

Additional info:
https://bugzilla.redhat.com/show_bug.cgi?id=1302121 shows similar type of bug , but resolution provided there with https://rhn.redhat.com/errata/RHSA-2017-0013.html#Red%20Hat%20Enterprise%20Linux%20Server%20 update does'nt seems to work.

Comment 2 David Kaspar // Dee'Kej 2017-02-20 14:23:36 UTC
(In reply to Yogita from comment #0)
> Version-Release number of selected component (if applicable):
> Rhel 7.3
> Package - ghostscript.9.07.20

Please, provide the complete NVR of the package causing this issue. (Output of 'rpm -q ghostscript'...)

> How reproducible:
> The problem can also be reproduced using ImageMagick command
> /usr/bin/convert:

How often is this reproducible? Every time? 5/10 runs? I will try to reproduce it, but specify it next time, please. Thank you.

Comment 3 David Kaspar // Dee'Kej 2017-02-20 14:24:10 UTC
*** Bug 1422491 has been marked as a duplicate of this bug. ***

Comment 5 Yogita 2017-02-22 04:49:54 UTC
(In reply to David Kaspar [Dee'Kej] from comment #2)
> (In reply to Yogita from comment #0)
> > Version-Release number of selected component (if applicable):
> > Rhel 7.3
> > Package - ghostscript.9.07.20
> 
> Please, provide the complete NVR of the package causing this issue. (Output
> of 'rpm -q ghostscript'...)

rpm -q ghostscript
ghostscript-9.07-20.el7_3.1.x86_64

> > How reproducible:
> > The problem can also be reproduced using ImageMagick command
> > /usr/bin/convert:
> 
> How often is this reproducible? Every time? 5/10 runs? I will try to
> reproduce it, but specify it next time, please. Thank you.

This issue have happened everytime.

Comment 7 dbodnarc 2017-02-22 08:58:40 UTC
I have the customer with exactly the same problem.


PDF document details used are the following:
------------------------------------------------
Producer: Adobe PDF Library 9.0
Creator:  Adobe InDesign CS4 (6.0.6)
Format:   PDF-1.7
------------------------------------------------

Enviroment:
[root@fastvm-r7-3-73 ~]# rpm -q ghostscript ImageMagick
ghostscript-9.07-20.el7_3.1.x86_64
ImageMagick-6.7.8.9-15.el7_2.x86_64

Reproducer:
[root@fastvm-r7-3-73 ~]# /usr/bin/convert /tmp/TRUMPF-5-year-warranty-conditions-brochures.pdf /tmp/test.gif

Results:
>> gs consumes 100% CPU and the process never ends 

[root@fastvm-r7-3-73 ~]# ps faux 
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root      2148  0.0  0.2 143392  2580 ?        Ss   Feb21   0:01  \_ sshd: root@pts/0
root      2181  0.0  0.2 116040  2420 pts/0    Ss   Feb21   0:00  |   \_ -bash
root      3221  0.1  0.8 232980  8472 pts/0    S+   09:36   0:00  |       \_ /usr/bin/convert /tmp/TRUMPF-5-year-warranty-conditions-brochures.pdf /tmp/test.gif
root      3222  100  3.3 135768 34016 pts/0    R+   09:36   0:30  |           \_ gs -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sDEVICE=pam -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r72x72 -dUseCIEColor -sOutputFile=/tmp/magick-RFYIggoO-%08d -f/tmp/magick-TvgwyvY6 -f/tmp/magick-11inBPyp

I'm also attaching strace output for your reference (strace-gs100p-cpu.txt)

A workaround for avoiding such behavior before patch release is welcome.

Comment 15 David Kaspar // Dee'Kej 2017-03-14 18:27:35 UTC
Created attachment 1263033 [details]
possible fix [from git bisect]

I have isolated the possible fix for this issue by git-bisect.

Comment 18 David Kaspar // Dee'Kej 2017-03-20 13:50:29 UTC
Comment on attachment 1263033 [details]
possible fix [from git bisect]

So, even upstream says what I have noticed there. The 'for' loop uses wrong variable (i) for incrementation, instead of variable 'k', so eventually the program will get stuck in the loop.

Comment 19 Kamil Dudka 2017-03-20 13:58:37 UTC
Comment on attachment 1263033 [details]
possible fix [from git bisect]

Looks good.

Comment 33 errata-xmlrpc 2017-08-01 23:03:50 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2017:2180

Comment 34 Red Hat Bugzilla 2023-09-14 03:53:55 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days