Bug 687044 - strange elements with text
Summary: strange elements with text
Status: NOTIFIED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: master
Hardware: All All
: P2 normal
Assignee: Igor Melichev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-09-12 08:55 UTC by Jack Moffitt
Modified: 2008-12-19 08:31 UTC (History)
1 user (show)

See Also:
Customer: 411
Word Size: ---


Attachments
Bug1344-.ps (717.08 KB, application/postscript)
2003-09-15 02:54 UTC, Igor Melichev
Details
Stack after crash (6.92 KB, text/plain)
2003-09-15 12:12 UTC, Erik Strik
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jack Moffitt 2003-09-12 08:55:35 UTC
After distilling the attached test file with GS from CVS HEAD, the last page
(page  5) has some strange elements by the text.  This file works fine in 8.00,
but starts to display this problem in 8.11.
Comment 1 Jack Moffitt 2003-09-12 09:00:51 UTC
Created attachment 281 [details]
Illustrator5.zip
Comment 2 Jack Moffitt 2003-09-12 09:10:10 UTC
Created attachment 282 [details]
Bug1344.ps

This file also exhibits the same problem more clearly I believe.
Comment 3 Igor Melichev 2003-09-15 02:54:19 UTC
Created attachment 285 [details]
Bug1344-.ps 

Attaching a reduced test that reproduce the problem.
It is made from Bug1344.ps by manual deletion of other texts.
The problematic text is painted with a Type 3 font, which's CharProc uses
another Type 3 font and a Type 1 font. Probably something is wrong with text
matrices in this case. Colors are strange as well.
Comment 4 Erik Strik 2003-09-15 03:24:17 UTC
These files also causes (sometimes) crash on Windows. See stack dump below 
when interpreting Illustrator5.ps:

gsdll32.dll!names_index_ref(const name_table_s * nt=0x017957f8, unsigned int 
index=24750624, ref_s * pnref=0x0012c5ec)  Line 279 + 0x12 C

gsdll32.dll!glyph_ref(unsigned long glyph=24750624, ref_s * gref=0x0012c5ec)  
Line 366 + 0x14 C

gsdll32.dll!z1_glyph_info_generic(gs_font_s * font=0x02b9c478, unsigned long 
glyph=24750624, const gs_matrix_s * pmat=0x0012c820, int members=41, 
gs_glyph_info_s * info=0x0012c7ac, int (gs_font_s *, unsigned long, const 
gs_matrix_s *, int, gs_glyph_info_s *)* proc=0x024325f4, int wmode=0)  Line 
1134 + 0xd C

gsdll32.dll!z1_glyph_info(gs_font_s * font=0x02b9c478, unsigned long 
glyph=24750624, const gs_matrix_s * pmat=0x0012c820, int members=41, 
gs_glyph_info_s * info=0x0012c7ac)  Line 1201 + 0x22 C

gsdll32.dll!compare_glyphs(const gs_font_s * cfont=0x02969518, const gs_font_s 
* ofont=0x02b9c478, unsigned long * glyphs=0x0012c91c, int num_glyphs=2, int 
level=1)  Line 714 + 0x23 C

gsdll32.dll!compare_glyphs(const gs_font_s * cfont=0x02969518, const gs_font_s 
* ofont=0x02b9c478, unsigned long * glyphs=0x0012cc24, int num_glyphs=1, int 
level=0)  Line 749 + 0x1c C

gsdll32.dll!gs_copied_can_copy_glyphs(const gs_font_s * cfont=0x02969518, 
const gs_font_s * ofont=0x02b9c478, unsigned long * glyphs=0x0012cc24, int 
num_glyphs=1, int check_hinting=1)  Line 2089 + 0x17 C

gsdll32.dll!pdf_find_font_resource(gx_device_pdf_s * pdev=0x020edba8, 
gs_font_s * font=0x02b9c478, int type=5, pdf_font_resource_s * * 
ppdfont=0x0012cf90, unsigned long * glyphs=0x0012cc24, unsigned long * 
chars=0x0012cc2c, int num_chars=1)  Line 722 + 0x17 C

gsdll32.dll!pdf_obtain_font_resource(const gs_text_enum_s * penum=0x02b9cf68, 
const gs_string_s * pstr=0x0012d004, pdf_font_resource_s * * 
ppdfont=0x0012cf90)  Line 1154 + 0x33 C

gsdll32.dll!pdf_encode_string(gx_device_pdf_s * pdev=0x020edba8, const 
pdf_text_enum_s * penum=0x02b9cf68, const gs_string_s * pstr=0x0012d004, 
pdf_font_resource_s * * ppdfont=0x0012cfc0)  Line 141 + 0x11 C

gsdll32.dll!pdf_encode_process_string(pdf_text_enum_s * penum=0x02b9cf68, 
gs_string_s * pstr=0x0012d004, const gs_matrix_s * pfmat=0x00000000, 
pdf_text_process_state_s * ppts=0x0012d010)  Line 74 + 0x15 C

gsdll32.dll!process_plain_text(gs_text_enum_s * pte=0x02b9cf68, void * 
vbuf=0x0012d088, unsigned int bsize=1)  Line 970 + 0x13 C

gsdll32.dll!pdf_text_process(gs_text_enum_s * pte=0x02b9cf68)  Line 1698 + 0xf 
C

gsdll32.dll!gs_text_process(gs_text_enum_s * pte=0x02b9cf68)  Line 460 + 0xd C 
gsdll32.dll!op_show_continue_pop(gs_context_state_s * i_ctx_p=0x020c96a0, int 
npop=1)  Line 456 + 0x12 C

gsdll32.dll!zshow(gs_context_state_s * i_ctx_p=0x020c96a0)  Line 62 + 0xb C

gsdll32.dll!interp(gs_context_state_s * * pi_ctx_p=0x0270c41c, const ref_s * 
pref=0x0012d794, ref_s * perror_object=0x0270c3fc)  Line 1122 + 0xa C

gsdll32.dll!gs_call_interp(gs_context_state_s * * pi_ctx_p=0x0270c41c, ref_s * 
pref=0x0012d794, int user_errors=0, int * pexit_code=0x0012d7dc, ref_s * 
perror_object=0x0270c3fc)  Line 487 + 0x11 C

gsdll32.dll!gs_interpret(gs_context_state_s * * pi_ctx_p=0x0270c41c, ref_s * 
pref=0x0012d794, int user_errors=0, int * pexit_code=0x0012d7dc, ref_s * 
perror_object=0x0270c3fc)  Line 446 + 0x19 C

gsdll32.dll!gs_main_interpret(gs_main_instance_s * minst=0x0270c218, ref_s * 
pref=0x0012d794, int user_errors=0, int * pexit_code=0x0012d7dc, ref_s * 
perror_object=0x0270c3fc)  Line 211 + 0x1f C

gsdll32.dll!gs_main_run_string_continue(gs_main_instance_s * minst=0x0270c218, 
const char * str=0x0165cff8, unsigned int length=51200, int user_errors=0, int 
* pexit_code=0x0012d7dc, ref_s * perror_object=0x0270c3fc)  Line 590 + 0x19 C

gsdll32.dll!gsapi_run_string_continue(gs_main_instance_s * minst=0x0270c218, 
const char * str=0x0165cff8, unsigned int length=51200, int user_errors=0, int 
* pexit_code=0x0012d7dc)  Line 175 + 0x22 C

gsdll32.dll!gsdll_execute_cont(const char * str=0x0165cff8, int len=51200)  
Line 123 + 0x19 C

..... More application stack
Comment 5 Igor Melichev 2003-09-15 11:00:32 UTC
The file Bug1344.ps has 3 problems :

1. Colors are not written to charproc which doesn't call setcachedevice[2].
   It is fixed with the patch
   http://www.ghostscript.com/pipermail/gs-cvs/2003-September/003604.html .

2. An indeterministic failure in PS interpreter with a random error code.
   Maybe it casues the crash mentioned by Erik Strik.
   Fixed with the patch 
   http://www.ghostscript.com/pipermail/gs-cvs/2003-September/003603.html .

3. Some characters are cut off.
   Probably it's a clipping problem with Type 3 fonts.
   The corresponding code fragment was written without a strong definition.
   To be analyzed.

4. The strange text elements appear due to hinting of 1-pixel font size, which 
appears during the Type 3 charproc accumulation. A suggested patch 
http://www.ghostscript.com/pipermail/gs-code-review/2003-September/004113.html
is sent to code review, because I need an additional information about an old 
GS solution.




Comment 6 Igor Melichev 2003-09-15 11:03:19 UTC
Dear Erik Strik,

Please try patches mentioned in my previous followup.
Possibly http://www.ghostscript.com/pipermail/gs-cvs/2003-September/003603.html 
fixes the crash you mentioned.

In future please don't put big logs into followups. Instead please put them as 
attachments. Thank you.
Comment 7 Ray Johnston 2003-09-15 11:46:40 UTC
Testing with HEAD as of 9 AM PDT Sept 15, 2003 I still am able
to reproduce the SEGV in names_index_ref. This occurs during the
recursive call to compare_glyphs, where the 'pieces' array 
appears to have garbage in it.
Comment 8 Erik Strik 2003-09-15 12:12:29 UTC
Created attachment 287 [details]
Stack after crash

Dear Igor,

Thank you for the quick fixes of my problems. The problem with the damaged
characters has been solved.

Unfortunately two problems remain:

1. The in
http://www.ghostscript.com/pipermail/gs-cvs/2003-September/003603.html
mentioned fix in gsdps1.c does not fix my crash in "Illustrator5.ps". The
mentioned fix, fixes a problem introduced after gs8_11. The crash I have is
occuring in gs8_01, gs8_11 and CVS_HEAD.
The crash occurs in compare_glyps, called by gs_copy_can_copy_glyphs with
probably invalid values.

2. Some characters are missing from "Illustrator5.ps". In the last page (the
Pantone plate) "0%" is missing twice. In the middle of the page it should show
"40%" and "60%". The "4" and "6" where previously damaged (fixed now). The "0%"
is missing.

Maybe the missing "0%" is related to the crash. If you inspect the stack it
shows invalid glyph indexes passed to compare_glyphs.
Pleas bare in mind that this crash happens in 1 of 3 occasions and pdfwrite is
called with our fixed set of parameters as seen in GSTest.exe

Kind regards,

Erik Strik
Comment 9 Igor Melichev 2003-09-15 12:29:11 UTC
The problem with character cut off happens due to the font /|O_____Folio-Medium 
defines FontBBox [0 0 1 1] but the character 'p' has part outside [0 0 1 1]. 
With raster devices this isn't important because its charproc used 
setcharwidth, i.e. the raster isn't cached and isn't clipped.

The pdfwrite's problem is that it always sets a clip in charproc. It is used to 
cancel the full page clip while entering the charproc accumulation (gdevpdtt.c 
ln 166). This code fragment to be rewrtitten without an artificial clip, rather 
the fix isn't obvious and isn't surely possible. Will try to fix it soon.
Comment 10 Igor Melichev 2003-09-16 03:06:09 UTC
The patch http://www.ghostscript.com/pipermail/gs-code-review/2003-
September/004113.html
(the point '4' above) has been committed as 
http://www.ghostscript.com/pipermail/gs-cvs/2003-September/003607.html
Note the improved log message.
Comment 11 Igor Melichev 2003-09-16 05:13:24 UTC
Patch
http://www.ghostscript.com/pipermail/gs-cvs/2003-September/003608.html
fixes the problem (3).
Comment 12 Igor Melichev 2003-09-16 05:31:45 UTC
I confirm the crash with Illustrator5.ps .
The chash isn't deterministic.
In the debugger session of Visual Sdudio 6 it happens with gswin32c.exe, but 
doesn't happen with gswin32.exe . Also setting -dCompatibilityLevel=1.3 avoids 
the crash (the latter must not be considered as a suggested workaround).

However I don't confirm the problem with "40%" and "60%". With the current CVS 
HEAD (after the patch http://www.ghostscript.com/pipermail/gs-cvs/2003-
September/003608.html) the text looks fine. BTW, I can see 62% rather than 60%, 
both with pdfwrite and display devices.
Comment 13 Igor Melichev 2003-09-16 06:56:30 UTC
The patch
http://www.ghostscript.com/pipermail/gs-cvs/2003-September/003609.html
fixes the crash with Illustrator5.ps .
Comment 14 Igor Melichev 2003-09-30 04:44:08 UTC
The patch
http://www.ghostscript.com/pipermail/gs-cvs/2003-September/003610.html
was committed by a mistake. It was replaced with a correct one
http://www.ghostscript.com/pipermail/gs-cvs/2003-September/003611.html ,
which makes same changes with a different log message.

Igor.