Bug 52215 - Division by zero in poppler/PSOutputDev.cc:3132
Summary: Division by zero in poppler/PSOutputDev.cc:3132
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: utils (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-17 21:55 UTC by Octoploid
Modified: 2012-07-22 16:41 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
testcase (39.37 KB, application/x-www-form-urlencoded)
2012-07-17 21:55 UTC, Octoploid
Details
solves floating point exception (804 bytes, patch)
2012-07-21 06:34 UTC, Thomas Freitag
Details | Splinter Review

Description Octoploid 2012-07-17 21:55:51 UTC
Created attachment 64336 [details]
testcase

% gdb pdftops
(gdb) run -origpagesizes /tmp/foo.pdf
Starting program: /usr/bin/pdftops -origpagesizes /tmp/foo.pdf

Program received signal SIGFPE, Arithmetic exception.
0x00007ffff7cd254a in PSOutputDev::checkPageSlice (this=0x435ba0, page=0x4359b0, rotateA=0, useMediaBox=<optimized out>, crop=false, sliceX=0, 
    sliceY=0, sliceW=0, sliceH=0, printing=true, abortCheckCbk=0, abortCheckCbkData=0x0, annotDisplayDecideCbk=0, annotDisplayDecideCbkData=0x0)
    at /var/tmp/portage/app-text/poppler-0.20.2/work/poppler-0.20.2/poppler/PSOutputDev.cc:3132
3132      stripeH = (sliceH + nStripes - 1) / nStripes;
(gdb) bt
#0  0x00007ffff7cd254a in PSOutputDev::checkPageSlice (this=0x435ba0, page=0x4359b0, rotateA=0, useMediaBox=<optimized out>, crop=false, sliceX=0, 
    sliceY=0, sliceW=0, sliceH=0, printing=true, abortCheckCbk=0, abortCheckCbkData=0x0, annotDisplayDecideCbk=0, annotDisplayDecideCbkData=0x0)
    at /var/tmp/portage/app-text/poppler-0.20.2/work/poppler-0.20.2/poppler/PSOutputDev.cc:3132
#1  0x00007ffff7cbcac3 in Page::displaySlice (this=0x4359b0, out=0x435ba0, hDPI=<optimized out>, vDPI=<optimized out>, rotate=0, useMediaBox=false, 
    crop=true, sliceX=sliceX@entry=-1, sliceY=sliceY@entry=-1, sliceW=sliceW@entry=-1, sliceH=sliceH@entry=-1, printing=true, 
    abortCheckCbk=abortCheckCbk@entry=0, abortCheckCbkData=abortCheckCbkData@entry=0x0, annotDisplayDecideCbk=annotDisplayDecideCbk@entry=0, 
    annotDisplayDecideCbkData=annotDisplayDecideCbkData@entry=0x0)
    at /var/tmp/portage/app-text/poppler-0.20.2/work/poppler-0.20.2/poppler/Page.cc:507
#2  0x00007ffff7cbccfe in Page::display (this=<optimized out>, out=<optimized out>, hDPI=<optimized out>, vDPI=<optimized out>, 
    rotate=<optimized out>, useMediaBox=<optimized out>, crop=<optimized out>, printing=<optimized out>, abortCheckCbk=0, abortCheckCbkData=0x0, 
    annotDisplayDecideCbk=0, annotDisplayDecideCbkData=0x0) at /var/tmp/portage/app-text/poppler-0.20.2/work/poppler-0.20.2/poppler/Page.cc:450
#3  0x00007ffff7cc22c5 in PDFDoc::displayPages (this=0x434d90, out=0x435ba0, firstPage=<optimized out>, lastPage=1, hDPI=72, vDPI=72, rotate=0, 
    useMediaBox=false, crop=true, printing=true, abortCheckCbk=0, abortCheckCbkData=0x0, annotDisplayDecideCbk=0, annotDisplayDecideCbkData=0x0)
    at /var/tmp/portage/app-text/poppler-0.20.2/work/poppler-0.20.2/poppler/PDFDoc.cc:483
#4  0x0000000000402840 in main (argc=2, argv=<optimized out>) at /var/tmp/portage/app-text/poppler-0.20.2/work/poppler-0.20.2/utils/pdftops.cc:398

This happens with certain pdfs produced by cups.
See: https://bugs.gentoo.org/show_bug.cgi?id=426674 or
https://bugs.gentoo.org/show_bug.cgi?id=426552

Started with commit 6ee907f2.
Comment 1 Albert Astals Cid 2012-07-17 22:09:44 UTC
I receive mails already, don't want them twice thanks
Comment 2 Thomas Freitag 2012-07-18 07:24:46 UTC
In PSOutputDev::startPage, case mode == psModePSOrigPageSizes (line 3524), the initialization of xScale and yScale is missing, should be imo as in the other cases beside psModePS
     xScale = yScale = 1;
(i.e. insert before line 3551)
Without it, the calculation of hDPI2 and vDPI2(line 3117 ff) and therefore the calculation of stripes causes this floating point exception.
Should I upload a new patch for bug 51982 which includes it, wait that it will be committed and create then a patch here or can You do that, Albert?
Comment 3 Thomas Freitag 2012-07-20 07:38:32 UTC
Albert?
Comment 4 Albert Astals Cid 2012-07-20 07:52:37 UTC
Wait until i commit the one for 51982, regtesting almost done there, don't want to start again, takes ages :D
Comment 5 Albert Astals Cid 2012-07-20 22:03:54 UTC
Patch for 51982 pushed
Comment 6 Thomas Freitag 2012-07-21 06:34:29 UTC
Created attachment 64480 [details] [review]
solves floating point exception

Here now my patch for it. The patch is slightly different to my suggested solution in comment 2 but does the same and is more secure for futur code changes.
Comment 7 Albert Astals Cid 2012-07-22 16:41:19 UTC
Pushed


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.