diff options
author | Ray Johnston <ray.johnston@artifex.com> | 2016-04-25 15:45:41 -0700 |
---|---|---|
committer | Ray Johnston <ray.johnston@artifex.com> | 2016-04-26 08:28:18 -0700 |
commit | 341a0b9a1268cb246c1e0cc12d684a59b39cf876 (patch) | |
tree | e220d7428920c6102624c1f3f27665a569d0b1a3 | |
parent | 979d208cb52fb7fda65d742aa09311067c60aba6 (diff) | |
download | ghostpdl-341a0b9a1268cb246c1e0cc12d684a59b39cf876.tar.gz |
Fix nocm (-dUseFastColor) allocation when using NumRenderingThreads>0
Rendering threads use a chunk_memory allocator that is, by nature, not
GC'ed so its non_gc_memory points to itself, but the icc_cache_cl of the
(and the icc_cache_list[]) link caches use thread_safe_memory (the heap
allocator) so when the thread exits, we have "leaked" nocm elements from
the chunk allocator (seen with a DEBUG build) and end up with stale pointers
in the link_cache that cause SEGV when the link cache's contents are removed.
Problem seen with:
-dNOCIE -dUseFastColor -dNumRenderingThreads=1 -dMaxBitmap=0 j9_acrobat.pdf
-rw-r--r-- | base/gsicc_cache.c | 8 | ||||
-rw-r--r-- | base/gsicc_nocm.c | 5 |
2 files changed, 5 insertions, 8 deletions
diff --git a/base/gsicc_cache.c b/base/gsicc_cache.c index 7ba956b9e..f9122cb5a 100644 --- a/base/gsicc_cache.c +++ b/base/gsicc_cache.c @@ -141,7 +141,6 @@ icc_linkcache_finalize(const gs_memory_t *mem, void *ptr) while (link_cache->head != NULL) { gsicc_remove_link(link_cache->head, mem); - link_cache->num_links--; } #ifdef DEBUG if (link_cache->num_links != 0) { @@ -566,6 +565,7 @@ gsicc_remove_link(gsicc_link_t *link, const gs_memory_t *memory) curr = curr->next; } /* if curr != link we didn't find it: assert ? */ + icc_link_cache->num_links--; /* no longer in the cache */ gx_monitor_leave(icc_link_cache->lock); gsicc_link_free(link, memory); /* outside link */ } @@ -785,7 +785,6 @@ gsicc_alloc_link_entry(gsicc_link_cache_t *icc_link_cache, /* the outermost 'while' will check to make sure some other */ /* thread did not grab the one we remove. */ gsicc_remove_link(link, cache_mem); - icc_link_cache->num_links--; } /* insert an empty link that we will reserve so we */ /* can unlock while building the link contents */ @@ -966,7 +965,6 @@ gsicc_get_link_profile(const gs_imager_state *pis, gx_device *dev, nor any defaults to use for this. Really need to throw an error for this case. */ gsicc_remove_link(link, cache_mem); - icc_link_cache->num_links--; return NULL; } } @@ -999,7 +997,6 @@ gsicc_get_link_profile(const gs_imager_state *pis, gx_device *dev, nor any defaults to use for this. Really need to throw an error for this case. */ gsicc_remove_link(link, cache_mem); - icc_link_cache->num_links--; return NULL; } } @@ -1017,7 +1014,6 @@ gsicc_get_link_profile(const gs_imager_state *pis, gx_device *dev, } else { /* Cant create the link */ gsicc_remove_link(link, cache_mem); - icc_link_cache->num_links--; return NULL; } } @@ -1035,7 +1031,6 @@ gsicc_get_link_profile(const gs_imager_state *pis, gx_device *dev, } else { /* Cant create the link */ gsicc_remove_link(link, cache_mem); - icc_link_cache->num_links--; return NULL; } } @@ -1114,7 +1109,6 @@ gsicc_get_link_profile(const gs_imager_state *pis, gx_device *dev, (long long)gs_output_profile->hashcode); } else { gsicc_remove_link(link, cache_mem); - icc_link_cache->num_links--; return NULL; } return link; diff --git a/base/gsicc_nocm.c b/base/gsicc_nocm.c index 372f95823..48cebe6e9 100644 --- a/base/gsicc_nocm.c +++ b/base/gsicc_nocm.c @@ -329,6 +329,7 @@ gsicc_nocm_copy_curve(gx_transfer_map *in_map, gs_memory_t *mem) out_map = (gx_transfer_map*) gs_alloc_bytes(mem, sizeof(gx_transfer_map), "gsicc_nocm_copy_curve"); if (out_map) { + memset(out_map, 0, sizeof(gx_transfer_map)); out_map->proc = in_map->proc; memcpy(&(out_map->values[0]), &(in_map->values[0]), sizeof(frac) * transfer_map_size); @@ -347,7 +348,7 @@ gsicc_nocm_get_link(const gs_imager_state *pis, gx_device *dev, gsicc_link_t *result; gsicc_hashlink_t hash; nocm_link_t *nocm_link; - gs_memory_t *mem = pis->memory->non_gc_memory; + gs_memory_t *mem = pis->icc_link_cache->memory->non_gc_memory; bool pageneutralcolor = false; cmm_dev_profile_t *dev_profile; int code; @@ -411,6 +412,8 @@ gsicc_nocm_get_link(const gs_imager_state *pis, gx_device *dev, "gsicc_nocm_get_link"); if (nocm_link->pis == NULL) return NULL; + memset(nocm_link->pis, 0, sizeof(gs_imager_state)); + /* Note if allocation of either of the maps fails, just use NULL */ nocm_link->pis->black_generation = (gx_transfer_map*) gsicc_nocm_copy_curve(pis->black_generation, mem); nocm_link->pis->undercolor_removal = (gx_transfer_map*) |