Bug 692637 - out of memory crash when processing PLRM.pdf on 1st generation iPad
Summary: out of memory crash when processing PLRM.pdf on 1st generation iPad
Status: RESOLVED FIXED
Alias: None
Product: MuPDF
Classification: Unclassified
Component: mupdf (show other bugs)
Version: unspecified
Hardware: Other other
: P4 normal
Assignee: Tor Andersson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-29 17:16 UTC by Arthur Ford
Modified: 2011-10-31 13:00 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
PostScript Language Reference Manual (7.41 MB, application/pdf)
2011-10-29 17:16 UTC, Arthur Ford
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arthur Ford 2011-10-29 17:16:42 UTC
Created attachment 8049 [details]
PostScript Language Reference Manual

After selecting PLRM.pdf on a 1st generation iPad running iOS 4.3.3, it processes PLRM.pdf for a moment and then fails.

The console messages say:
applicationDidBecomeActive!
open xref '/var/mobile/Applications/BCE161B2-EF18-4965-A23B-B0023B205B39/Documents/PLRM.pdf'
loading page 0 for size 768 x 1004
fatal error: out of memory (integer overflow)

The debugger stack says:
Program received signal:  “SIGABRT”
[...]
#0  0x33850a1c in __pthread_kill ()
#1  0x369413ba in pthread_kill ()
#2  0x36939bfe in abort ()
#3  0x00008b68 in fz_calloc (count=41041, size=130892) at fitz/base_memory.c:26
#4  0x0001f696 in fz_new_pixmap_with_data (colorspace=0x641de0, w=32723, h=41041, samples=0x0) at fitz/res_pixmap.c:38
#5  0x0001f81a in fz_new_pixmap (colorspace=0x641de0, w=32723, h=41041) at fitz/res_pixmap.c:62
#6  0x0001f870 in fz_new_pixmap_with_rect (colorspace=0x641de0, r={x0 = -35249, y0 = -41041, x1 = -2526, y1 = 0}) at fitz/res_pixmap.c:69
#7  0x00004446 in renderPage (xref=0x4424000, number=0, width=768, height=1004) at /Users/artford/ghostscript/tor/mupdf/ios/main.m:165
#8  0x00004042 in __35-[MuDocumentController reloadPage:]_block_invoke_0 (.block_descriptor=0x46e2b90) at /Users/artford/ghostscript/tor/mupdf/ios/main.m:427
Comment 1 Arthur Ford 2011-10-30 04:23:58 UTC
Looks like the scale factors were off.  The following resolved the problem:

diff --git a/ios/main.m b/ios/main.m
index 89614fc..1aeaa6e 100644
--- a/ios/main.m
+++ b/ios/main.m
@@ -153,8 +153,8 @@ static UIImage *renderPage(pdf_xref *xref, int number, float
                return nil;
        }
 
-       hscale = width / page->mediabox.x1 - page->mediabox.x0;
-       vscale = height / page->mediabox.y1 - page->mediabox.y0;
+       hscale = width / (page->mediabox.x1 - page->mediabox.x0);
+       vscale = height / (page->mediabox.y1 - page->mediabox.y0);
        scale = MIN(hscale, vscale);
 
        ctm = fz_translate(0, -page->mediabox.y1);
Comment 2 Tor Andersson 2011-10-31 13:00:16 UTC
Gah! Thanks for spotting this!