diff options
author | Chris Liddell <chris.liddell@artifex.com> | 2020-09-29 20:16:10 +0100 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2020-09-30 17:41:57 +0100 |
commit | be33716b4a6d42f9bd5a5485514dbaeb9e9524b2 (patch) | |
tree | bd8c5c8d9e1b1be2a8841480a8150efcef4175a1 | |
parent | 27824a749775a233725cf3f302ce8156c478f7e1 (diff) | |
download | ghostpdl-be33716b4a6d42f9bd5a5485514dbaeb9e9524b2.tar.gz |
Bug 702948: Ensure initial bitmap cache sizes are properly aligned
Now that the allocations from the bitmap cache are aligned to the platform's
required alignment, see commit:
260c443bc14cdffa4d94e14c3a57e35bebee3a5b
We also want the initial size of the memory pool used by the cache to be
"aligned".
This is so that code that attempts to identify cache entries to evict by
requesting a size equal to the entire size of cache memory pool doesn't get an
unexpected failure, because we've rounded up that allocation request to a value
larger than the entire size of the memory pool.
Because we don't expect an error to be possible at that point, a crash can
occur.
Of the "normal" platforms we use, this only exhibits on Win32 because that is
the only platform where the align_bitmap_mod we use is less than the
obj_align_mod used for the memory managers.
-rw-r--r-- | base/gxccman.c | 5 | ||||
-rw-r--r-- | base/gxclist.c | 3 | ||||
-rw-r--r-- | base/lib.mak | 6 |
3 files changed, 10 insertions, 4 deletions
diff --git a/base/gxccman.c b/base/gxccman.c index b2d84305a..29880b224 100644 --- a/base/gxccman.c +++ b/base/gxccman.c @@ -34,6 +34,7 @@ #include "gxxfont.h" #include "gxttfb.h" #include "gxfont42.h" +#include "gxobj.h" /* Define the descriptors for the cache structures. */ private_st_cached_fm_pair(); @@ -932,8 +933,8 @@ alloc_char(gs_font_dir * dir, ulong icdsize, cached_char **pcc) gs_memory_t *mem = dir->ccache.bits_memory; char_cache_chunk *cck_prev = dir->ccache.chunks; char_cache_chunk *cck; - uint cksize = dir->ccache.bmax / 5 + 1; - uint tsize = dir->ccache.bmax - dir->ccache.bspace; + uint cksize = ROUND_UP(dir->ccache.bmax / 5 + 1, obj_align_mod); + uint tsize = ROUND_UP(dir->ccache.bmax - dir->ccache.bspace, obj_align_mod); byte *cdata; if (cksize > tsize) diff --git a/base/gxclist.c b/base/gxclist.c index 9df5f7c9d..a5a9fa619 100644 --- a/base/gxclist.c +++ b/base/gxclist.c @@ -31,6 +31,7 @@ #include "gsicc_manage.h" #include "gsicc_cache.h" #include "gxdevsop.h" +#include "gxobj.h" #include "valgrind.h" @@ -410,6 +411,8 @@ clist_init_data(gx_device * dev, byte * init_data, uint data_size) int code; int align = 1 << (target->log2_align_mod > log2_align_bitmap_mod ? target->log2_align_mod : log2_align_bitmap_mod); + align = align < obj_align_mod ? obj_align_mod : align; + /* the clist writer has its own color info that depends upon the transparency group color space (if transparency exists). The data that is used in the clist writing. Here it is initialized with diff --git a/base/lib.mak b/base/lib.mak index 368edeb62..59f64b0d4 100644 --- a/base/lib.mak +++ b/base/lib.mak @@ -693,7 +693,8 @@ $(GLOBJ)gxccman.$(OBJ) : $(GLSRC)gxccman.c $(AK) $(gx_h) $(gserrors_h)\ $(memory__h) $(gpcheck_h)\ $(gsbitops_h) $(gsstruct_h) $(gsutil_h) $(gxfixed_h) $(gxmatrix_h)\ $(gxdevice_h) $(gxdevmem_h) $(gxfont_h) $(gxfcache_h) $(gxchar_h)\ - $(gxpath_h) $(gxxfont_h) $(gzstate_h) $(gxttfb_h) $(gxfont42_h) $(LIB_MAK) $(MAKEDIRS) + $(gxpath_h) $(gxxfont_h) $(gzstate_h) $(gxttfb_h) $(gxfont42_h) $(gxobj_h) \ + $(LIB_MAK) $(MAKEDIRS) $(GLCC) $(GLO_)gxccman.$(OBJ) $(C_) $(GLSRC)gxccman.c $(GLOBJ)gxchar.$(OBJ) : $(GLSRC)gxchar.c $(AK) $(gx_h) $(gserrors_h)\ @@ -2203,7 +2204,8 @@ $(GLD)clist.dev : $(LIB_MAK) $(ECHOGS_XE) $(clist_)\ $(GLOBJ)gxclist.$(OBJ) : $(GLSRC)gxclist.c $(AK) $(gx_h) $(gserrors_h)\ $(memory__h) $(string__h) $(gp_h) $(gpcheck_h) $(gsparams_h) $(valgrind_h)\ $(gxcldev_h) $(gxclpath_h) $(gxdevice_h) $(gxdevmem_h) $(gxdcolor_h)\ - $(gscms_h) $(gsicc_manage_h) $(gsicc_cache_h) $(gxdevsop_h) $(LIB_MAK) $(MAKEDIRS) + $(gscms_h) $(gsicc_manage_h) $(gsicc_cache_h) $(gxdevsop_h) $(gxobj_h) \ + $(LIB_MAK) $(MAKEDIRS) $(GLCC) $(GLO_)gxclist.$(OBJ) $(C_) $(GLSRC)gxclist.c $(GLOBJ)gxclbits.$(OBJ) : $(GLSRC)gxclbits.c $(AK) $(gx_h)\ |