From bbcf3c6fcfaa43741a774c902fd06cf3d9dae9d1 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Thu, 16 May 2013 17:36:13 +0100 Subject: [PATCH] Upstream patch to increase max object size to 16M (bug #880375). --- ghostscript-obj-size.patch | 132 +++++++++++++++++++++++++++++++++++++ ghostscript.spec | 9 ++- 2 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 ghostscript-obj-size.patch diff --git a/ghostscript-obj-size.patch b/ghostscript-obj-size.patch new file mode 100644 index 0000000..1b7ef7c --- /dev/null +++ b/ghostscript-obj-size.patch @@ -0,0 +1,132 @@ +diff -up ghostscript-9.06/doc/Language.htm.obj-size ghostscript-9.06/doc/Language.htm +--- ghostscript-9.06/doc/Language.htm.obj-size 2012-08-08 09:01:37.000000000 +0100 ++++ ghostscript-9.06/doc/Language.htm 2013-05-16 17:34:50.428601551 +0100 +@@ -231,25 +231,25 @@ shown. +   + array +   +- 65535 ++ 16777216 +   + elements +   +-   ++ 65535 + dictionary +   +- 65534 ++ 16777215 +   + elements +   + 65535 + string +   +- 65535 ++ 16777216 +   + characters +   +-   ++ 65535 + name +   + 16383 +@@ -381,10 +381,14 @@ starts with a %...% IODevice designation +

Other differences in VM consumption

+ +

+-Packed array elements occupy either 2 bytes or 8 bytes. The average +-element size is probably about 5 bytes. Names occupy 12 bytes plus the ++In 32-bit builds packed array elements occupy either 2 bytes or 12 bytes. ++The average element size is probably about 7 bytes. Names occupy 16 bytes plus the + space for the string. +

++In 64-bit builds packed array elements occupy either 2 bytes or 16 bytes. ++The average element size is probably about 9 bytes. ++Names occupy 24 bytes plus the space for the string. ++

+ The garbage collector doesn't reclaim portions of arrays obtained with + getinterval, rather it collects entire arrays. +


+diff -up ghostscript-9.06/psi/igcref.c.obj-size ghostscript-9.06/psi/igcref.c +--- ghostscript-9.06/psi/igcref.c.obj-size 2012-08-08 09:01:36.000000000 +0100 ++++ ghostscript-9.06/psi/igcref.c 2013-05-16 17:34:50.458601694 +0100 +@@ -745,7 +745,7 @@ refs_compact(const gs_memory_t *mem, obj + } + #endif + /* Pad to a multiple of sizeof(ref). */ +- while (new_size & (sizeof(ref) - 1)) ++ while (new_size % sizeof(ref)) + *dest++ = pt_tag(pt_integer), + new_size += sizeof(ref_packed); + /* We want to make the newly freed space into a free block, */ +diff -up ghostscript-9.06/psi/int.mak.obj-size ghostscript-9.06/psi/int.mak +--- ghostscript-9.06/psi/int.mak.obj-size 2013-05-16 17:34:26.682488246 +0100 ++++ ghostscript-9.06/psi/int.mak 2013-05-16 17:34:50.459601698 +0100 +@@ -64,7 +64,7 @@ iname_h=$(PSSRC)iname.h $(inames_h) + inameidx_h=$(PSSRC)inameidx.h + inamestr_h=$(PSSRC)inamestr.h $(inameidx_h) + ipacked_h=$(PSSRC)ipacked.h +-iref_h=$(PSSRC)iref.h ++iref_h=$(PSSRC)iref.h $(stdint__h) + isave_h=$(PSSRC)isave.h $(idosave_h) + isstate_h=$(PSSRC)isstate.h + istruct_h=$(PSSRC)istruct.h $(gsstruct_h) +diff -up ghostscript-9.06/psi/iref.h.obj-size ghostscript-9.06/psi/iref.h +--- ghostscript-9.06/psi/iref.h.obj-size 2012-08-08 09:01:36.000000000 +0100 ++++ ghostscript-9.06/psi/iref.h 2013-05-16 17:34:50.459601698 +0100 +@@ -19,6 +19,8 @@ + #ifndef iref_INCLUDED + # define iref_INCLUDED + ++#include "stdint_.h" ++ + /* + * Note: this file defines a large number of macros. Many of these are + * only used for internal purposes within this file, to help in the +@@ -375,7 +377,7 @@ typedef int (*op_proc_t)(i_ctx_t *i_ctx_ + struct tas_s { + /* type_attrs is a single element for fast dispatching in the interpreter */ + ushort type_attrs; +- ushort rsize; ++ uint32_t rsize; + }; + struct ref_s { + +@@ -558,10 +560,10 @@ struct ref_s { + (((ARCH_ALIGN_LONG_MOD - 1) | (ARCH_ALIGN_FLOAT_MOD - 1) |\ + (ARCH_ALIGN_PTR_MOD - 1)) + 1) + +-/* Define the maximum size of an array or a string. */ +-/* The maximum array size is determined by the fact that */ +-/* the allocator cannot allocate a block larger than max_uint. */ +-#define max_array_size (max_ushort & (max_uint / (uint)arch_sizeof_ref)) +-#define max_string_size max_ushort ++/* Select reasonable values for PDF interpreter */ ++/* The maximum array size cannot exceed max_uint/arch_sizeof_ref */ ++/* because the allocator cannot allocate a block larger than max_uint. */ ++#define max_array_size (16*1024*1024) ++#define max_string_size (16*1024*1024) + + #endif /* iref_INCLUDED */ +diff -up ghostscript-9.06/psi/zpacked.c.obj-size ghostscript-9.06/psi/zpacked.c +--- ghostscript-9.06/psi/zpacked.c.obj-size 2012-08-08 09:01:36.000000000 +0100 ++++ ghostscript-9.06/psi/zpacked.c 2013-05-16 17:34:50.460601703 +0100 +@@ -68,7 +68,6 @@ zsetpacking(i_ctx_t *i_ctx_p) + { + os_ptr op = osp; + ref cont; +- + check_type(*op, t_boolean); + make_struct(&cont, avm_local, ref_array_packing_container); + ref_assign_old(&cont, &ref_array_packing, op, "setpacking"); +@@ -151,7 +150,7 @@ make_packed_array(ref * parr, ref_stack_ + } + ishort = idest += packed_per_ref; + } +- pad = -(int)idest & (packed_per_ref - 1); /* padding at end */ ++ pad = (packed_per_ref - idest % packed_per_ref) % packed_per_ref; /* padding at end */ + + /* Now we can allocate the array. */ + diff --git a/ghostscript.spec b/ghostscript.spec index 89d0768..cf2f73b 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -5,7 +5,7 @@ Summary: A PostScript interpreter and renderer Name: ghostscript Version: %{gs_ver} -Release: 5%{?dist} +Release: 6%{?dist} # Included CMap data is Redistributable, no modification permitted, # see http://bugzilla.redhat.com/487510 @@ -27,6 +27,7 @@ Patch27: ghostscript-Fontmap.local.patch Patch28: ghostscript-iccprofiles-initdir.patch Patch29: ghostscript-gdevcups-debug-uninit.patch Patch30: ghostscript-pdfwrite-segfault.patch +Patch31: ghostscript-obj-size.patch Requires: urw-fonts >= 1.1, ghostscript-fonts Requires: poppler-data @@ -143,6 +144,9 @@ rm -rf expat freetype icclib jasper jpeg lcms2 libpng openjpeg zlib cups/libs # Upstream patch to fix pdfwrite segfault (bug #962120). %patch30 -p1 -b .pdfwrite-segfault +# Upstream patch to increase max object size to 16M (bug #880375). +%patch31 -p1 -b .obj-size + # Convert manual pages to UTF-8 from8859_1() { iconv -f iso-8859-1 -t utf-8 < "$1" > "${1}_" @@ -339,6 +343,9 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libgs.so %changelog +* Thu May 16 2013 Tim Waugh 9.06-6 +- Upstream patch to increase max object size to 16M (bug #880375). + * Thu May 16 2013 Tim Waugh 9.06-5 - Upstream patch to fix pdfwrite segfault (bug #962120).