Bug 697661 - tiffsep1 dvice is not compatible with threshold array-based halftones
Summary: tiffsep1 dvice is not compatible with threshold array-based halftones
Status: NOTIFIED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Other Driver (show other bugs)
Version: master
Hardware: PC Windows 7
: P4 normal
Assignee: Ray Johnston
URL:
Keywords:
: 693505 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-03-10 13:07 UTC by Ken Sharp
Modified: 2018-02-13 08:22 UTC (History)
2 users (show)

See Also:
Customer: 531
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ken Sharp 2017-03-10 13:07:22 UTC
Created attachment 13465 [details]
type 5 halftone with type 3 sub-halftones (threshold arrays)

The (to be attached) files include a type 5 halftone with type sub-dictionaries for each colourant. When run with the tiffsep1 device this causes a segmentation fault in threshold_from_order() at around line 2174 in gdevtsep.c

This appears to be because the code in this function is expecting that the data pointed to by the opaque pointer in d_order->bit_data will be an array of gx_ht_bit structures, from which it will construct a threshold array.

However, in gxhtbit.c, construct_ht_order_short() (around line 79) we appear to be filling the memory pointed to by bit_data with actual threshold array values.

Its entirely possible that I'm missing soemthing here (this is not an area I know much about), but it looks like there is a disconnect between the data being stored in the pointer between the two ends.

I don't really think its great that tiffsep1 is doing its own halftoning, it would be better if it was using the graphics library. However, in any event it should not crash.
Comment 1 Ken Sharp 2017-03-10 13:09:02 UTC
Created attachment 13466 [details]
original PDF file exposing the problem (almost certainly any file will actually do the same)

Executing the type 5 halftone with type 3 sub-halftones, then sending this file to Ghostscript will result in a crash.
Comment 2 Ken Sharp 2017-03-10 13:10:09 UTC
Created attachment 13467 [details]
type 5 halftone with type 1 sub-halftones

Using this hlftone instead of the threshold arrays version will not crash.
Comment 3 Ken Sharp 2017-03-10 13:16:24 UTC
According to 'who owns what' the tiffsep1 device is owned by Henry and Ray. Going by a short discussion today (around 17:00) on #artifex, it looks like Ray is more likely the correct person to look at this problem.
Comment 4 Ray Johnston 2017-03-12 18:15:33 UTC
Fixed in commit 16b7f4

Threshold arrays create a different type of gx_ht_order than screen type
halftones so the bit_data is short X,Y coordinates instead of offset,mask
(gx_ht_bit) elements that the tiffsep1 "threshold_from_order" code was
expecting. Using the bit_index proc of the order works for all gx_ht_order
types.

TODO: determine if it is possible to use the gx_ht_construct_threshold
function. This function is used in the FAST_HT_CODE used for some
images to halftone devices that need halftoning.
Comment 5 Ray Johnston 2018-02-13 08:22:21 UTC
*** Bug 693505 has been marked as a duplicate of this bug. ***