[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft-devel] avoiding a longjmp crash in ftgrays.c
From: |
Tom Bishop, Wenlin Institute |
Subject: |
Re: [ft-devel] avoiding a longjmp crash in ftgrays.c |
Date: |
Mon, 27 Dec 2010 09:38:51 -0800 |
Dear FreeTypers,
A very short program (freetype_debug_gray.c) demonstrates the crash:
#include <stdio.h>
#include <string.h>
#include <ft2build.h>
#include FT_FREETYPE_H
static char *DebugFreeType(void)
{
FT_Library ttEngine;
if (FT_Init_FreeType(&ttEngine) != 0) {
return "FT_Init_FreeType error";
}
char ttName[] = "MYFONT.TTF";
FT_Face face;
if (FT_New_Face(ttEngine, ttName, 0, &face) != 0) {
return "FT_New_Face error";
}
FT_Set_Charmap(face, face->charmaps[1]);
FT_Set_Pixel_Sizes(face, 0, 162);
FT_Load_Glyph(face, 7211, FT_LOAD_RENDER | FT_LOAD_NO_BITMAP);
return "OK";
} // DebugFreeType
int main(void)
{
char *s = DebugFreeType();
printf("%s\n", s);
if (strcmp(s, "OK") != 0) {
return -1;
}
return 0;
} // main
==========================
Unless there is a bug in that code, it seems the bug must be in MinGW GCC (4.5
and 3.4.4), or MS-Windows 7/Vista/XP, or FreeType 2.4.4. Possibly there is
something the matter with MYFONT.TTF; still, ideally FreeType shouldn't crash
no matter what is in the font. If anyone is willing and able to investigate
this, I'll try to come up with a smaller font containing just one glyph that
causes the same crash. (Glyph 7211 is actually fairly simple, with only one
contour; it's not the more intricate one with which the problem first occurred.)
This is the makefile:
CC = mingw32-gcc
CXX = mingw32-g++
#CC=i386-mingw32-gcc
#CXX = i386-mingw32-g++
vpath %.c ../c \
../freetype/src/autohint ../freetype/src/bdf ../freetype/src/cff
../freetype/src/cache ../freetype/src/gzip \
../freetype/src/base ../freetype/src/pcf ../freetype/src/pfr
../freetype/src/psaux ../freetype/src/pshinter \
../freetype/src/psnames ../freetype/src/raster ../freetype/src/sfnt
../freetype/src/smooth ../freetype/src/truetype \
../freetype/src/type1 ../freetype/src/cid ../freetype/src/type42
../freetype/src/winfonts ../freetype/src/lzw \
../freetype/src/autofit
INCLUDE =-I../freetype/include -I../freetype/include/freetype
OPT_FLAGS = -Os -ggdb -fomit-frame-pointer
# OPT_FLAGS = -Os -ggdb -fno-omit-frame-pointer
CFLAGS = $(OPT_FLAGS) -mwindows -DUNICODE=1 -Wall $(INCLUDE)
-DFT_DEBUG_LEVEL_TRACE -DFT_DEBUG_MEMORY -DFT_AVOID_LONGJMP=0
OBJS = \
freetype_debug_gray.o \
bdf.o cff.o ftbase.o ftcache.o ftglyph.o ftgzip.o ftinit.o \
ftsystem.o pcf.o pfr.o psaux.o pshinter.o psnames.o raster.o \
sfnt.o smooth.o truetype.o type1.o type1cid.o type42.o winfnt.o
fttype1.o \
ftbitmap.o ftlzw.o autofit.o \
ftdebug.o
freetype_debug_gray.exe: $(OBJS)
$(CC) -static $(CFLAGS) $(OBJS) -o $@
# Automatically generate dependencies, save them in .d files
%.d: %.c
$(CC) -MM $(CFLAGS) $< > $@
depends = $(OBJS:.o=.d)
include $(depends)
clean:
del *.o *.d *.exe
=========================
I set the debug level and run the program like this at the Windows XP command
line (to capture stdout and stderr):
set FT2_DEBUG=any:5
freetype_debug_gray > test_crash.txt 2>&1
The resulting file test_crash.txt is this:
Init_Context: new object at 0x003D77B8
FT_Stream_Open: opened `MYFONT.TTF' (10904212 bytes) successfully
sfnt_open_font: synthesize TTC
sfnt_init_face: 003D9310, 0
tt_face_load_font_dir: 003D9310
-- Number of tables: 14
-- Format version: 0x00010000
tag offset length checksum
----------------------------------
OS/2 000000ec 0000004e caf25b27
cmap 0000013c 00000720 d133e179
cvt 0000085c 00000010 02e801e8
fpgm 0000086c 00000153 c960b19b
glyf 000009c0 00a4e902 492c51de
head 00a4f2c4 00000036 d925c905
hhea 00a4f2fc 00000024 072e2ff1
hmtx 00a4f320 0000b63c 4f077d01
loca 00a5a95c 0000b640 5ec518e4
maxp 00a65f9c 00000020 2fb507c1
mort 00a65fbc 00000000 00000000
name 00a65fbc 000002a2 de87d200
post 00a66260 00000020 00030066
prep 00a66280 00000013 bf3658bc
table directory loaded
sfnt_load_face: 003D9310
tt_face_lookup_table: 003D9310, `glyf' -- found table.
`head' -->
tt_face_lookup_table: 003D9310, `head' -- found table.
Units per EM: 1000
IndexToLoc: 1
loaded
`maxp' -->
tt_face_lookup_table: 003D9310, `maxp' -- found table.
numGlyphs: 11663
loaded
`cmap' -->
tt_face_lookup_table: 003D9310, `cmap' -- found table.
loaded
`name' -->
tt_face_lookup_table: 003D9310, `name' -- found table.
loaded
`post' -->
tt_face_lookup_table: 003D9310, `post' -- found table.
FormatType: 0x30000
isFixedPitch: no
loaded
`hhea' -->
tt_face_lookup_table: 003D9310, `hhea' -- found table.
Ascender: 930
Descender: -225
number_Of_Metrics: 11663
loaded
`hmtx' -->
tt_face_lookup_table: 003D9310, `hmtx' -- found table.
loaded
`vertical hhea' -->
tt_face_lookup_table: 003D9310, `vhea' -- could not find table
missing
`os2' -->
tt_face_lookup_table: 003D9310, `OS/2' -- found table.
sTypoAscender: 750
sTypoDescender: -170
usWinAscent: 930
usWinDescent: 225
fsSelection: 0x 0
loaded
`eblc' -->
tt_face_lookup_table: 003D9310, `EBLC' -- could not find table
tt_face_lookup_table: 003D9310, `bloc' -- could not find table
missing
`pclt' -->
tt_face_lookup_table: 003D9310, `PCLT' -- could not find table
missing
`gasp' -->
tt_face_lookup_table: 003D9310, `gasp' -- could not find table
missing
`kern' -->
tt_face_lookup_table: 003D9310, `kern' -- could not find table
missing
tt_face_lookup_table: 003D9310, `glyf' -- found table.
tt_face_lookup_table: 003D9310, `fvar' -- could not find table
sfnt_load_face: done
tt_face_lookup_table: 003D9310, `hdmx' -- could not find table
tt_face_lookup_table: 003D9310, `glyf' -- found table.
Locations tt_face_lookup_table: 003D9310, `loca' -- found table.
glyph count mismatch! loca: 11664, maxp: 11663
loaded
CVT tt_face_lookup_table: 003D9310, `cvt ' -- found table.
loaded
Font program tt_face_lookup_table: 003D9310, `fpgm' -- found table.
loaded, 339 bytes
Prep program tt_face_lookup_table: 003D9310, `prep' -- found table.
loaded, 19 bytes
FT_Open_Face: New face object, adding to list
FT_Open_Face: Creating glyph slot
FT_New_GlyphSlot: Creating new slot object
FT_New_GlyphSlot: Return 0
FT_Open_Face: Creating size object
FT_Open_Face: Return 0
Executing `fpgm' table.
Executing `prep' table.
tt_loader_init: grayscale change, re-executing `prep' table
Executing `prep' table.
tt_face_lookup_table: 003D9310, `glyf' -- found table.
advance width (font units): 1000
left side bearing (font units): 112
advance height (font units): 1000
top side bearing (font units): 0
Glyph 7211
# of contours: 1
xMin: 112 xMax: 888
yMin: -134 yMax: 820
Instructions size: 47
x advance: 10368
y advance: 0
linear x advance: 10616828
linear y advance: 9767482
FT_Outline_Decompose: Outline 0
move to (126.78, 97.33)
conic to (125.64, 99.59) with control (126.78, 98.63)
conic to (120.38, 103.47) with control (123.05, 101.53)
conic to (114.95, 107.20) with control (117.70, 105.42)
conic to (103.77, 114.56) with control (109.28, 111.25)
conic to (92.52, 120.33) with control (98.27, 117.89)
conic to (80.53, 124.14) with control (86.77, 122.77)
con
==============================
The output suddenly stops with "con", when the program crashes. Probably some
output is lost (unflushed buffer?); I doubt the crash occurs in the middle of
printing "conic".
There is an interesting warning, "glyph count mismatch!".
I change FT_AVOID_LONGJMP from 0 to 1 in the makefile, clean, recompile, and
run like this:
freetype_debug_gray > test_no_crash.txt 2>&1
The resulting file test_no_crash.txt is this:
Init_Context: new object at 0x003D77B8
FT_Stream_Open: opened `MYFONT.TTF' (10904212 bytes) successfully
sfnt_open_font: synthesize TTC
sfnt_init_face: 003D9310, 0
tt_face_load_font_dir: 003D9310
-- Number of tables: 14
-- Format version: 0x00010000
tag offset length checksum
----------------------------------
OS/2 000000ec 0000004e caf25b27
cmap 0000013c 00000720 d133e179
cvt 0000085c 00000010 02e801e8
fpgm 0000086c 00000153 c960b19b
glyf 000009c0 00a4e902 492c51de
head 00a4f2c4 00000036 d925c905
hhea 00a4f2fc 00000024 072e2ff1
hmtx 00a4f320 0000b63c 4f077d01
loca 00a5a95c 0000b640 5ec518e4
maxp 00a65f9c 00000020 2fb507c1
mort 00a65fbc 00000000 00000000
name 00a65fbc 000002a2 de87d200
post 00a66260 00000020 00030066
prep 00a66280 00000013 bf3658bc
table directory loaded
sfnt_load_face: 003D9310
tt_face_lookup_table: 003D9310, `glyf' -- found table.
`head' -->
tt_face_lookup_table: 003D9310, `head' -- found table.
Units per EM: 1000
IndexToLoc: 1
loaded
`maxp' -->
tt_face_lookup_table: 003D9310, `maxp' -- found table.
numGlyphs: 11663
loaded
`cmap' -->
tt_face_lookup_table: 003D9310, `cmap' -- found table.
loaded
`name' -->
tt_face_lookup_table: 003D9310, `name' -- found table.
loaded
`post' -->
tt_face_lookup_table: 003D9310, `post' -- found table.
FormatType: 0x30000
isFixedPitch: no
loaded
`hhea' -->
tt_face_lookup_table: 003D9310, `hhea' -- found table.
Ascender: 930
Descender: -225
number_Of_Metrics: 11663
loaded
`hmtx' -->
tt_face_lookup_table: 003D9310, `hmtx' -- found table.
loaded
`vertical hhea' -->
tt_face_lookup_table: 003D9310, `vhea' -- could not find table
missing
`os2' -->
tt_face_lookup_table: 003D9310, `OS/2' -- found table.
sTypoAscender: 750
sTypoDescender: -170
usWinAscent: 930
usWinDescent: 225
fsSelection: 0x 0
loaded
`eblc' -->
tt_face_lookup_table: 003D9310, `EBLC' -- could not find table
tt_face_lookup_table: 003D9310, `bloc' -- could not find table
missing
`pclt' -->
tt_face_lookup_table: 003D9310, `PCLT' -- could not find table
missing
`gasp' -->
tt_face_lookup_table: 003D9310, `gasp' -- could not find table
missing
`kern' -->
tt_face_lookup_table: 003D9310, `kern' -- could not find table
missing
tt_face_lookup_table: 003D9310, `glyf' -- found table.
tt_face_lookup_table: 003D9310, `fvar' -- could not find table
sfnt_load_face: done
tt_face_lookup_table: 003D9310, `hdmx' -- could not find table
tt_face_lookup_table: 003D9310, `glyf' -- found table.
Locations tt_face_lookup_table: 003D9310, `loca' -- found table.
glyph count mismatch! loca: 11664, maxp: 11663
loaded
CVT tt_face_lookup_table: 003D9310, `cvt ' -- found table.
loaded
Font program tt_face_lookup_table: 003D9310, `fpgm' -- found table.
loaded, 339 bytes
Prep program tt_face_lookup_table: 003D9310, `prep' -- found table.
loaded, 19 bytes
FT_Open_Face: New face object, adding to list
FT_Open_Face: Creating glyph slot
FT_New_GlyphSlot: Creating new slot object
FT_New_GlyphSlot: Return 0
FT_Open_Face: Creating size object
FT_Open_Face: Return 0
Executing `fpgm' table.
Executing `prep' table.
tt_loader_init: grayscale change, re-executing `prep' table
Executing `prep' table.
tt_face_lookup_table: 003D9310, `glyf' -- found table.
advance width (font units): 1000
left side bearing (font units): 112
advance height (font units): 1000
top side bearing (font units): 0
Glyph 7211
# of contours: 1
xMin: 112 xMax: 888
yMin: -134 yMax: 820
Instructions size: 47
x advance: 10368
y advance: 0
linear x advance: 10616828
linear y advance: 9767482
FT_Outline_Decompose: Outline 0
move to (126.78, 97.33)
conic to (125.64, 99.59) with control (126.78, 98.63)
conic to (120.38, 103.47) with control (123.05, 101.53)
conic to (114.95, 107.20) with control (117.70, 105.42)
conic to (103.77, 114.56) with control (109.28, 111.25)
conic to (92.52, 120.33) with control (98.27, 117.89)
conic to (80.53, 124.14) with control (86.77, 122.77)
conic to (67.00, 125.67) with control (74.30, 125.52)
conic to (67.00, 138.95) with control (67.00, 132.48)
conic to (67.00, 152.25) with control (67.00, 145.44)
conic to (66.11, 154.27) with control (67.00, 153.53)
conic to (64.00, 155.00) with control (65.23, 155.00)
conic to (61.00, 152.25) with control (61.00, 155.00)
conic to (61.00, 138.88) with control (61.00, 145.44)
conic to (61.00, 125.67) with control (61.00, 132.31)
conic to (47.80, 121.70) with control (54.69, 125.03)
conic to (34.34, 113.92) with control (40.91, 118.39)
conic to (21.80, 104.36) with control (27.80, 109.47)
conic to (11.11, 95.06) with control (15.80, 99.27)
conic to (6.33, 90.75) with control (8.67, 92.78)
conic to (1.70, 86.47) with control (3.98, 88.73)
conic to (0.73, 84.53) with control (0.73, 85.83)
conic to (1.55, 82.50) with control (0.73, 83.39)
conic to (3.48, 81.61) with control (2.36, 81.61)
conic to (5.28, 82.42) with control (4.47, 81.61)
conic to (10.45, 87.03) with control (8.03, 84.69)
conic to (15.64, 91.66) with control (12.89, 89.39)
conic to (25.36, 100.16) with control (19.86, 95.55)
conic to (36.86, 108.91) with control (30.88, 104.78)
conic to (49.02, 116.19) with control (42.86, 113.03)
conic to (61.00, 120.00) with control (55.17, 119.36)
conic to (60.19, 102.27) with control (60.67, 111.09)
conic to (58.25, 84.69) with control (59.70, 93.44)
conic to (53.63, 65.81) with control (56.63, 74.16)
conic to (46.17, 50.34) with control (50.64, 57.47)
conic to (35.72, 36.73) with control (41.72, 43.22)
conic to (21.95, 23.30) with control (29.73, 30.25)
conic to (11.91, 14.53) with control (16.94, 18.75)
conic to (1.70, 5.95) with control (6.89, 10.33)
conic to (0.73, 4.02) with control (0.73, 5.14)
conic to (1.55, 1.98) with control (0.73, 2.88)
conic to (3.48, 1.09) with control (2.36, 1.09)
conic to (5.28, 1.75) with control (4.30, 1.09)
conic to (15.97, 10.66) with control (10.63, 6.13)
conic to (26.50, 19.89) with control (21.31, 15.19)
conic to (39.38, 32.61) with control (33.63, 26.38)
conic to (49.66, 45.64) with control (45.13, 38.84)
conic to (57.44, 60.22) with control (54.20, 52.45)
conic to (62.59, 77.56) with control (60.67, 68.00)
conic to (72.02, 59.17) with control (67.31, 67.52)
conic to (82.14, 43.30) with control (76.72, 50.83)
conic to (93.80, 28.55) with control (87.56, 35.77)
conic to (107.50, 13.56) with control (100.05, 21.34)
conic to (113.23, 7.42) with control (110.41, 10.50)
conic to (119.16, 1.42) with control (116.08, 4.34)
conic to (121.11, 0.45) with control (120.13, 0.45)
conic to (123.05, 1.34) with control (122.23, 0.45)
conic to (123.86, 3.36) with control (123.86, 2.23)
conic to (123.05, 5.31) with control (123.86, 4.17)
conic to (114.70, 13.97) with control (118.83, 9.69)
conic to (106.36, 22.80) with control (110.58, 18.27)
conic to (93.06, 38.11) with control (99.06, 30.75)
conic to (82.14, 53.17) with control (87.08, 45.48)
conic to (72.91, 69.38) with control (77.20, 60.88)
conic to (64.44, 88.09) with control (68.61, 77.89)
conic to (66.17, 104.13) with control (65.72, 96.19)
conic to (67.00, 120.17) with control (66.64, 112.06)
conic to (83.11, 117.81) with control (75.91, 120.00)
conic to (96.72, 112.22) with control (90.33, 115.63)
conic to (109.28, 104.38) with control (103.13, 108.83)
conic to (122.41, 95.06) with control (115.44, 99.92)
conic to (124.03, 94.56) with control (123.22, 94.56)
conic to (126.05, 95.38) with control (125.31, 94.56)
conic to (126.78, 97.33) with control (126.78, 96.19)
FT_Outline_Decompose: Done
FT_Outline_Decompose: Outline 0
move to (126.78, 97.33)
conic to (125.64, 99.59) with control (126.78, 98.63)
conic to (120.38, 103.47) with control (123.05, 101.53)
conic to (114.95, 107.20) with control (117.70, 105.42)
conic to (103.77, 114.56) with control (109.28, 111.25)
conic to (92.52, 120.33) with control (98.27, 117.89)
conic to (80.53, 124.14) with control (86.77, 122.77)
conic to (67.00, 125.67) with control (74.30, 125.52)
conic to (67.00, 138.95) with control (67.00, 132.48)
conic to (67.00, 152.25) with control (67.00, 145.44)
conic to (66.11, 154.27) with control (67.00, 153.53)
conic to (64.00, 155.00) with control (65.23, 155.00)
conic to (61.00, 152.25) with control (61.00, 155.00)
conic to (61.00, 138.88) with control (61.00, 145.44)
conic to (61.00, 125.67) with control (61.00, 132.31)
conic to (47.80, 121.70) with control (54.69, 125.03)
conic to (34.34, 113.92) with control (40.91, 118.39)
conic to (21.80, 104.36) with control (27.80, 109.47)
conic to (11.11, 95.06) with control (15.80, 99.27)
conic to (6.33, 90.75) with control (8.67, 92.78)
conic to (1.70, 86.47) with control (3.98, 88.73)
conic to (0.73, 84.53) with control (0.73, 85.83)
conic to (1.55, 82.50) with control (0.73, 83.39)
conic to (3.48, 81.61) with control (2.36, 81.61)
conic to (5.28, 82.42) with control (4.47, 81.61)
conic to (10.45, 87.03) with control (8.03, 84.69)
conic to (15.64, 91.66) with control (12.89, 89.39)
conic to (25.36, 100.16) with control (19.86, 95.55)
conic to (36.86, 108.91) with control (30.88, 104.78)
conic to (49.02, 116.19) with control (42.86, 113.03)
conic to (61.00, 120.00) with control (55.17, 119.36)
conic to (60.19, 102.27) with control (60.67, 111.09)
conic to (58.25, 84.69) with control (59.70, 93.44)
conic to (53.63, 65.81) with control (56.63, 74.16)
conic to (46.17, 50.34) with control (50.64, 57.47)
conic to (35.72, 36.73) with control (41.72, 43.22)
conic to (21.95, 23.30) with control (29.73, 30.25)
conic to (11.91, 14.53) with control (16.94, 18.75)
conic to (1.70, 5.95) with control (6.89, 10.33)
conic to (0.73, 4.02) with control (0.73, 5.14)
conic to (1.55, 1.98) with control (0.73, 2.88)
conic to (3.48, 1.09) with control (2.36, 1.09)
conic to (5.28, 1.75) with control (4.30, 1.09)
conic to (15.97, 10.66) with control (10.63, 6.13)
conic to (26.50, 19.89) with control (21.31, 15.19)
conic to (39.38, 32.61) with control (33.63, 26.38)
conic to (49.66, 45.64) with control (45.13, 38.84)
conic to (57.44, 60.22) with control (54.20, 52.45)
conic to (62.59, 77.56) with control (60.67, 68.00)
conic to (72.02, 59.17) with control (67.31, 67.52)
conic to (82.14, 43.30) with control (76.72, 50.83)
conic to (93.80, 28.55) with control (87.56, 35.77)
conic to (107.50, 13.56) with control (100.05, 21.34)
conic to (113.23, 7.42) with control (110.41, 10.50)
conic to (119.16, 1.42) with control (116.08, 4.34)
conic to (121.11, 0.45) with control (120.13, 0.45)
conic to (123.05, 1.34) with control (122.23, 0.45)
conic to (123.86, 3.36) with control (123.86, 2.23)
conic to (123.05, 5.31) with control (123.86, 4.17)
conic to (114.70, 13.97) with control (118.83, 9.69)
conic to (106.36, 22.80) with control (110.58, 18.27)
conic to (93.06, 38.11) with control (99.06, 30.75)
conic to (82.14, 53.17) with control (87.08, 45.48)
conic to (72.91, 69.38) with control (77.20, 60.88)
conic to (64.44, 88.09) with control (68.61, 77.89)
conic to (66.17, 104.13) with control (65.72, 96.19)
conic to (67.00, 120.17) with control (66.64, 112.06)
conic to (83.11, 117.81) with control (75.91, 120.00)
conic to (96.72, 112.22) with control (90.33, 115.63)
conic to (109.28, 104.38) with control (103.13, 108.83)
conic to (122.41, 95.06) with control (115.44, 99.92)
conic to (124.03, 94.56) with control (123.22, 94.56)
conic to (126.05, 95.38) with control (125.31, 94.56)
conic to (126.78, 97.33) with control (126.78, 96.19)
FT_Outline_Decompose: Done
FT_Outline_Decompose: Outline 0
move to (126.78, 97.33)
conic to (125.64, 99.59) with control (126.78, 98.63)
conic to (120.38, 103.47) with control (123.05, 101.53)
conic to (114.95, 107.20) with control (117.70, 105.42)
conic to (103.77, 114.56) with control (109.28, 111.25)
conic to (92.52, 120.33) with control (98.27, 117.89)
conic to (80.53, 124.14) with control (86.77, 122.77)
conic to (67.00, 125.67) with control (74.30, 125.52)
conOK
ic to (67.00, 138.95) with control (67.00, 132.48)
conic to (67.00, 152.25) with control (67.00, 145.44)
conic to (66.11, 154.27) with control (67.00, 153.53)
conic to (64.00, 155.00) with control (65.23, 155.00)
conic to (61.00, 152.25) with control (61.00, 155.00)
conic to (61.00, 138.88) with control (61.00, 145.44)
conic to (61.00, 125.67) with control (61.00, 132.31)
conic to (47.80, 121.70) with control (54.69, 125.03)
conic to (34.34, 113.92) with control (40.91, 118.39)
conic to (21.80, 104.36) with control (27.80, 109.47)
conic to (11.11, 95.06) with control (15.80, 99.27)
conic to (6.33, 90.75) with control (8.67, 92.78)
conic to (1.70, 86.47) with control (3.98, 88.73)
conic to (0.73, 84.53) with control (0.73, 85.83)
conic to (1.55, 82.50) with control (0.73, 83.39)
conic to (3.48, 81.61) with control (2.36, 81.61)
conic to (5.28, 82.42) with control (4.47, 81.61)
conic to (10.45, 87.03) with control (8.03, 84.69)
conic to (15.64, 91.66) with control (12.89, 89.39)
conic to (25.36, 100.16) with control (19.86, 95.55)
conic to (36.86, 108.91) with control (30.88, 104.78)
conic to (49.02, 116.19) with control (42.86, 113.03)
conic to (61.00, 120.00) with control (55.17, 119.36)
conic to (60.19, 102.27) with control (60.67, 111.09)
conic to (58.25, 84.69) with control (59.70, 93.44)
conic to (53.63, 65.81) with control (56.63, 74.16)
conic to (46.17, 50.34) with control (50.64, 57.47)
conic to (35.72, 36.73) with control (41.72, 43.22)
conic to (21.95, 23.30) with control (29.73, 30.25)
conic to (11.91, 14.53) with control (16.94, 18.75)
conic to (1.70, 5.95) with control (6.89, 10.33)
conic to (0.73, 4.02) with control (0.73, 5.14)
conic to (1.55, 1.98) with control (0.73, 2.88)
conic to (3.48, 1.09) with control (2.36, 1.09)
conic to (5.28, 1.75) with control (4.30, 1.09)
conic to (15.97, 10.66) with control (10.63, 6.13)
conic to (26.50, 19.89) with control (21.31, 15.19)
conic to (39.38, 32.61) with control (33.63, 26.38)
conic to (49.66, 45.64) with control (45.13, 38.84)
conic to (57.44, 60.22) with control (54.20, 52.45)
conic to (62.59, 77.56) with control (60.67, 68.00)
conic to (72.02, 59.17) with control (67.31, 67.52)
conic to (82.14, 43.30) with control (76.72, 50.83)
conic to (93.80, 28.55) with control (87.56, 35.77)
conic to (107.50, 13.56) with control (100.05, 21.34)
conic to (113.23, 7.42) with control (110.41, 10.50)
conic to (119.16, 1.42) with control (116.08, 4.34)
conic to (121.11, 0.45) with control (120.13, 0.45)
conic to (123.05, 1.34) with control (122.23, 0.45)
conic to (123.86, 3.36) with control (123.86, 2.23)
conic to (123.05, 5.31) with control (123.86, 4.17)
conic to (114.70, 13.97) with control (118.83, 9.69)
conic to (106.36, 22.80) with control (110.58, 18.27)
conic to (93.06, 38.11) with control (99.06, 30.75)
conic to (82.14, 53.17) with control (87.08, 45.48)
conic to (72.91, 69.38) with control (77.20, 60.88)
conic to (64.44, 88.09) with control (68.61, 77.89)
conic to (66.17, 104.13) with control (65.72, 96.19)
conic to (67.00, 120.17) with control (66.64, 112.06)
conic to (83.11, 117.81) with control (75.91, 120.00)
conic to (96.72, 112.22) with control (90.33, 115.63)
conic to (109.28, 104.38) with control (103.13, 108.83)
conic to (122.41, 95.06) with control (115.44, 99.92)
conic to (124.03, 94.56) with control (123.22, 94.56)
conic to (126.05, 95.38) with control (125.31, 94.56)
conic to (126.78, 97.33) with control (126.78, 96.19)
FT_Outline_Decompose: Done
========================
The glyph has only one contour, but FT_Outline_Decompose runs three times. It
seems to be plagued the first two times with ErrRaster_Memory_Overflow, causing
it to start over. The third time, stderr ("conic") and stdout ("OK") are
intertwined:
conOK
ic
Now I change -fomit-frame-pointer to -fno-omit-frame-pointer, change
FT_AVOID_LONGJMP back to 0, clean, recompile, and run again. This time it will
use longjmp successfully.
freetype_debug_gray > test_frame.txt 2>&1
The resulting file test_frame.txt is this:
Init_Context: new object at 0x003D77B8
FT_Stream_Open: opened `MYFONT.TTF' (10904212 bytes) successfully
sfnt_open_font: synthesize TTC
sfnt_init_face: 003D9310, 0
tt_face_load_font_dir: 003D9310
-- Number of tables: 14
-- Format version: 0x00010000
tag offset length checksum
----------------------------------
OS/2 000000ec 0000004e caf25b27
cmap 0000013c 00000720 d133e179
cvt 0000085c 00000010 02e801e8
fpgm 0000086c 00000153 c960b19b
glyf 000009c0 00a4e902 492c51de
head 00a4f2c4 00000036 d925c905
hhea 00a4f2fc 00000024 072e2ff1
hmtx 00a4f320 0000b63c 4f077d01
loca 00a5a95c 0000b640 5ec518e4
maxp 00a65f9c 00000020 2fb507c1
mort 00a65fbc 00000000 00000000
name 00a65fbc 000002a2 de87d200
post 00a66260 00000020 00030066
prep 00a66280 00000013 bf3658bc
table directory loaded
sfnt_load_face: 003D9310
tt_face_lookup_table: 003D9310, `glyf' -- found table.
`head' -->
tt_face_lookup_table: 003D9310, `head' -- found table.
Units per EM: 1000
IndexToLoc: 1
loaded
`maxp' -->
tt_face_lookup_table: 003D9310, `maxp' -- found table.
numGlyphs: 11663
loaded
`cmap' -->
tt_face_lookup_table: 003D9310, `cmap' -- found table.
loaded
`name' -->
tt_face_lookup_table: 003D9310, `name' -- found table.
loaded
`post' -->
tt_face_lookup_table: 003D9310, `post' -- found table.
FormatType: 0x30000
isFixedPitch: no
loaded
`hhea' -->
tt_face_lookup_table: 003D9310, `hhea' -- found table.
Ascender: 930
Descender: -225
number_Of_Metrics: 11663
loaded
`hmtx' -->
tt_face_lookup_table: 003D9310, `hmtx' -- found table.
loaded
`vertical hhea' -->
tt_face_lookup_table: 003D9310, `vhea' -- could not find table
missing
`os2' -->
tt_face_lookup_table: 003D9310, `OS/2' -- found table.
sTypoAscender: 750
sTypoDescender: -170
usWinAscent: 930
usWinDescent: 225
fsSelection: 0x 0
loaded
`eblc' -->
tt_face_lookup_table: 003D9310, `EBLC' -- could not find table
tt_face_lookup_table: 003D9310, `bloc' -- could not find table
missing
`pclt' -->
tt_face_lookup_table: 003D9310, `PCLT' -- could not find table
missing
`gasp' -->
tt_face_lookup_table: 003D9310, `gasp' -- could not find table
missing
`kern' -->
tt_face_lookup_table: 003D9310, `kern' -- could not find table
missing
tt_face_lookup_table: 003D9310, `glyf' -- found table.
tt_face_lookup_table: 003D9310, `fvar' -- could not find table
sfnt_load_face: done
tt_face_lookup_table: 003D9310, `hdmx' -- could not find table
tt_face_lookup_table: 003D9310, `glyf' -- found table.
Locations tt_face_lookup_table: 003D9310, `loca' -- found table.
glyph count mismatch! loca: 11664, maxp: 11663
loaded
CVT tt_face_lookup_table: 003D9310, `cvt ' -- found table.
loaded
Font program tt_face_lookup_table: 003D9310, `fpgm' -- found table.
loaded, 339 bytes
Prep program tt_face_lookup_table: 003D9310, `prep' -- found table.
loaded, 19 bytes
FT_Open_Face: New face object, adding to list
FT_Open_Face: Creating glyph slot
FT_New_GlyphSlot: Creating new slot object
FT_New_GlyphSlot: Return 0
FT_Open_Face: Creating size object
FT_Open_Face: Return 0
Executing `fpgm' table.
Executing `prep' table.
tt_loader_init: grayscale change, re-executing `prep' table
Executing `prep' table.
tt_face_lookup_table: 003D9310, `glyf' -- found table.
advance width (font units): 1000
left side bearing (font units): 112
advance height (font units): 1000
top side bearing (font units): 0
Glyph 7211
# of contours: 1
xMin: 112 xMax: 888
yMin: -134 yMax: 820
Instructions size: 47
x advance: 10368
y advance: 0
linear x advance: 10616828
linear y advance: 9767482
FT_Outline_Decompose: Outline 0
move to (126.78, 97.33)
conic to (125.64, 99.59) with control (126.78, 98.63)
conic to (120.38, 103.47) with control (123.05, 101.53)
conic to (114.95, 107.20) with control (117.70, 105.42)
conic to (103.77, 114.56) with control (109.28, 111.25)
conic to (92.52, 120.33) with control (98.27, 117.89)
conic to (80.53, 124.14) with control (86.77, 122.77)
conic to (67.00, 125.67) with control (74.30, 125.52)
conic to (67.00, 138.95) with control (67.00, 132.48)
conic to (67.00, 152.25) with control (67.00, 145.44)
conic to (66.11, 154.27) with control (67.00, 153.53)
conic to (64.00, 155.00) with control (65.23, 155.00)
conic to (61.00, 152.25) with control (61.00, 155.00)
conic to (61.00, 138.88) with control (61.00, 145.44)
conic to (61.00, 125.67) with control (61.00, 132.31)
conic to (47.80, 121.70) with control (54.69, 125.03)
conic to (34.34, 113.92) with control (40.91, 118.39)
conic to (21.80, 104.36) with control (27.80, 109.47)
conic to (11.11, 95.06) with control (15.80, 99.27)
conic to (6.33, 90.75) with control (8.67, 92.78)
conic to (1.70, 86.47) with control (3.98, 88.73)
conic to (0.73, 84.53) with control (0.73, 85.83)
conic to (1.55, 82.50) with control (0.73, 83.39)
conic to (3.48, 81.61) with control (2.36, 81.61)
conic to (5.28, 82.42) with control (4.47, 81.61)
conic to (10.45, 87.03) with control (8.03, 84.69)
conic to (15.64, 91.66) with control (12.89, 89.39)
conic to (25.36, 100.16) with control (19.86, 95.55)
conic to (36.86, 108.91) with control (30.88, 104.78)
conic to (49.02, 116.19) with control (42.86, 113.03)
conic to (61.00, 120.00) with control (55.17, 119.36)
conic to (60.19, 102.27) with control (60.67, 111.09)
conic to (58.25, 84.69) with control (59.70, 93.44)
conic to (53.63, 65.81) with control (56.63, 74.16)
conic to (46.17, 50.34) with control (50.64, 57.47)
conic to (35.72, 36.73) with control (41.72, 43.22)
conic to (21.95, 23.30) with control (29.73, 30.25)
conic to (11.91, 14.53) with control (16.94, 18.75)
conic to (1.70, 5.95) with control (6.89, 10.33)
conic to (0.73, 4.02) with control (0.73, 5.14)
conic to (1.55, 1.98) with control (0.73, 2.88)
conic to (3.48, 1.09) with control (2.36, 1.09)
conic to (5.28, 1.75) with control (4.30, 1.09)
conic to (15.97, 10.66) with control (10.63, 6.13)
conic to (26.50, 19.89) with control (21.31, 15.19)
conic to (39.38, 32.61) with control (33.63, 26.38)
conic to (49.66, 45.64) with control (45.13, 38.84)
conic to (57.44, 60.22) with control (54.20, 52.45)
conic to (62.59, 77.56) with control (60.67, 68.00)
conic to (72.02, 59.17) with control (67.31, 67.52)
conic to (82.14, 43.30) with control (76.72, 50.83)
conic to (93.80, 28.55) with control (87.56, 35.77)
conic to (107.50, 13.56) with control (100.05, 21.34)
conic to (113.23, 7.42) with control (110.41, 10.50)
conic to (119.16, 1.42) with control (116.08, 4.34)
conic to (121.11, 0.45) with control (120.13, 0.45)
conic to (123.05, 1.34) with control (122.23, 0.45)
conic to (123.86, 3.36) with control (123.86, 2.23)
conic to (123.05, 5.31) with control (123.86, 4.17)
conic to (114.70, 13.97) with control (118.83, 9.69)
conic to (106.36, 22.80) with control (110.58, 18.27)
conic to (93.06, 38.11) with control (99.06, 30.75)
conic to (82.14, 53.17) with control (87.08, 45.48)
conic to (72.91, 69.38) with control (77.20, 60.88)
FT_Outline_Decompose: Outline 0
move to (126.78, 97.33)
conic to (125.64, 99.59) with control (126.78, 98.63)
conic to (120.38, 103.47) with control (123.05, 101.53)
conic to (114.95, 107.20) with control (117.70, 105.42)
conic to (103.77, 114.56) with control (109.28, 111.25)
conic to (92.52, 120.33) with control (98.27, 117.89)
conic to (80.53, 124.14) with control (86.77, 122.77)
conic to (67.00, 125.67) with control (74.30, 125.52)
conic to (67.00, 138.95) with control (67.00, 132.48)
conic to (67.00, 152.25) with control (67.00, 145.44)
conic to (66.11, 154.27) with control (67.00, 153.53)
conic to (64.00, 155.00) with control (65.23, 155.00)
conic to (61.00, 152.25) with control (61.00, 155.00)
conic to (61.00, 138.88) with control (61.00, 145.44)
conic to (61.00, 125.67) with control (61.00, 132.31)
conic to (47.80, 121.70) with control (54.69, 125.03)
conic to (34.34, 113.92) with control (40.91, 118.39)
conic to (21.80, 104.36) with control (27.80, 109.47)
conic to (11.11, 95.06) with control (15.80, 99.27)
conic to (6.33, 90.75) with control (8.67, 92.78)
conic to (1.70, 86.47) with control (3.98, 88.73)
conic to (0.73, 84.53) with control (0.73, 85.83)
conic to (1.55, 82.50) with control (0.73, 83.39)
conic to (3.48, 81.61) with control (2.36, 81.61)
conic to (5.28, 82.42) with control (4.47, 81.61)
conic to (10.45, 87.03) with control (8.03, 84.69)
conic to (15.64, 91.66) with control (12.89, 89.39)
conic to (25.36, 100.16) with control (19.86, 95.55)
conic to (36.86, 108.91) with control (30.88, 104.78)
conic to (49.02, 116.19) with control (42.86, 113.03)
conic to (61.00, 120.00) with control (55.17, 119.36)
conic to (60.19, 102.27) with control (60.67, 111.09)
conic to (58.25, 84.69) with control (59.70, 93.44)
conic to (53.63, 65.81) with control (56.63, 74.16)
conic to (46.17, 50.34) with control (50.64, 57.47)
conic to (35.72, 36.73) with control (41.72, 43.22)
conic to (21.95, 23.30) with control (29.73, 30.25)
conic to (11.91, 14.53) with control (16.94, 18.75)
conic to (1.70, 5.95) with control (6.89, 10.33)
conic to (0.73, 4.02) with control (0.73, 5.14)
conic to (1.55, 1.98) with control (0.73, 2.88)
conic to (3.48, 1.09) with control (2.36, 1.09)
conic to (5.28, 1.75) with control (4.30, 1.09)
conic to (15.97, 10.66) with control (10.63, 6.13)
conic to (26.50, 19.89) with control (21.31, 15.19)
conic to (39.38, 32.61) with control (33.63, 26.38)
conic to (49.66, 45.64) with control (45.13, 38.84)
conic to (57.44, 60.22) with control (54.20, 52.45)
conic to (62.59, 77.56) with control (60.67, 68.00)
conic to (72.02, 59.17) with control (67.31, 67.52)
conic to (82.14, 43.30) with control (76.72, 50.83)
conic to (93.80, 28.55) with control (87.56, 35.77)
conic to (107.50, 13.56) with control (100.05, 21.34)
conic to (113.23, 7.42) with control (110.41, 10.50)
conic to (119.16, 1.42) with control (116.08, 4.34)
conic to (121.11, 0.45) with control (120.13, 0.45)
conic to (123.05, 1.34) with control (122.23, 0.45)
conic to (123.86, 3.36) with control (123.86, 2.23)
conic to (123.05, 5.31) with control (123.86, 4.17)
conic to (114.70, 13.97) with control (118.83, 9.69)
conic to (106.36, 22.80) with control (110.58, 18.27)
conic to (93.06, 38.11) with control (99.06, 30.75)
conic to (82.14, 53.17) with control (87.08, 45.48)
conic to (72.91, 69.38) with control (77.20, 60.88)
conic to (64.44, 88.09) with control (68.61, 77.89)
conic to (66.17, 104.13) with control (65.72, 96.19)
conic to (67.00, 120.17) with control (66.64, 112.06)
conic to (83.11, 117.81) with control (75.91, 120.00)
conic to (96.72, 112.22) with control (90.33, 115.63)
conic to (109.28, 104.38) with control (103.13, 108.83)
conic to (122.41, 95.06) with control (115.44, 99.92)
conic to (124.03, 94.56) with control (123.22, 94.56)
conic to (126.05, 95.38) with control (125.31, 94.56)
conic to (126.78, 97.33) with control (126.78, 96.19)
FT_Outline_Decompose: Done
FT_Outline_Decompose: Outline 0
move to (126.78, 97.33)
conic to (125.64, 99.59) with control (126.78, 98.63)
conic to (120.38, 103.47) with control (123.05, 101.53)
conic to (114.95, 107.20) with control (117.70, 105.42)
conic to (103.77, 114.56) with control (109.28, 111.25)
conic to (92.52, 120.33) with control (98.27, 117.89)
conic to (80.53, 124.14) with control (86.77, 122.77)
conic to (67.00, 125.67) with control (74.30, 125.52)
conic to (67.00, 138.95) with control (67.00, 132.48)
conic to (67.00, 152.25) with control (67.00, 145.44)
conic to (66.11, 154.27) with control (67.00, 153.53)
conic to (64.00, 155.00) with control (65.23, 155.00)
conic to (61.00, 152.25) with control (61.00, 155.00)
conic to (61.00, 138.88) with control (61.00, 145.44)
conic to (61.00, 125.67) with control (61.00, 132.31)
conic to (47.80, 121.70) with control (54.69, 125.03)
conic to (34.34, 113.92) with control (40.91, 118.39)
conic to (21.80, 104.36) with control (27.80, 109.47)
conic to (11.11, 95.06) with OK
control (15.80, 99.27)
conic to (6.33, 90.75) with control (8.67, 92.78)
conic to (1.70, 86.47) with control (3.98, 88.73)
conic to (0.73, 84.53) with control (0.73, 85.83)
conic to (1.55, 82.50) with control (0.73, 83.39)
conic to (3.48, 81.61) with control (2.36, 81.61)
conic to (5.28, 82.42) with control (4.47, 81.61)
conic to (10.45, 87.03) with control (8.03, 84.69)
conic to (15.64, 91.66) with control (12.89, 89.39)
conic to (25.36, 100.16) with control (19.86, 95.55)
conic to (36.86, 108.91) with control (30.88, 104.78)
conic to (49.02, 116.19) with control (42.86, 113.03)
conic to (61.00, 120.00) with control (55.17, 119.36)
conic to (60.19, 102.27) with control (60.67, 111.09)
conic to (58.25, 84.69) with control (59.70, 93.44)
conic to (53.63, 65.81) with control (56.63, 74.16)
conic to (46.17, 50.34) with control (50.64, 57.47)
conic to (35.72, 36.73) with control (41.72, 43.22)
conic to (21.95, 23.30) with control (29.73, 30.25)
conic to (11.91, 14.53) with control (16.94, 18.75)
conic to (1.70, 5.95) with control (6.89, 10.33)
conic to (0.73, 4.02) with control (0.73, 5.14)
conic to (1.55, 1.98) with control (0.73, 2.88)
conic to (3.48, 1.09) with control (2.36, 1.09)
conic to (5.28, 1.75) with control (4.30, 1.09)
conic to (15.97, 10.66) with control (10.63, 6.13)
conic to (26.50, 19.89) with control (21.31, 15.19)
conic to (39.38, 32.61) with control (33.63, 26.38)
conic to (49.66, 45.64) with control (45.13, 38.84)
conic to (57.44, 60.22) with control (54.20, 52.45)
conic to (62.59, 77.56) with control (60.67, 68.00)
conic to (72.02, 59.17) with control (67.31, 67.52)
conic to (82.14, 43.30) with control (76.72, 50.83)
conic to (93.80, 28.55) with control (87.56, 35.77)
conic to (107.50, 13.56) with control (100.05, 21.34)
conic to (113.23, 7.42) with control (110.41, 10.50)
conic to (119.16, 1.42) with control (116.08, 4.34)
conic to (121.11, 0.45) with control (120.13, 0.45)
conic to (123.05, 1.34) with control (122.23, 0.45)
conic to (123.86, 3.36) with control (123.86, 2.23)
conic to (123.05, 5.31) with control (123.86, 4.17)
conic to (114.70, 13.97) with control (118.83, 9.69)
conic to (106.36, 22.80) with control (110.58, 18.27)
conic to (93.06, 38.11) with control (99.06, 30.75)
conic to (82.14, 53.17) with control (87.08, 45.48)
conic to (72.91, 69.38) with control (77.20, 60.88)
conic to (64.44, 88.09) with control (68.61, 77.89)
conic to (66.17, 104.13) with control (65.72, 96.19)
conic to (67.00, 120.17) with control (66.64, 112.06)
conic to (83.11, 117.81) with control (75.91, 120.00)
conic to (96.72, 112.22) with control (90.33, 115.63)
conic to (109.28, 104.38) with control (103.13, 108.83)
conic to (122.41, 95.06) with control (115.44, 99.92)
conic to (124.03, 94.56) with control (123.22, 94.56)
conic to (126.05, 95.38) with control (125.31, 94.56)
conic to (126.78, 97.33) with control (126.78, 96.19)
FT_Outline_Decompose: Done
=============================
test_frame.txt is slightly different from test_no_crash.txt (although I think
the resulting bitmap is the same). The contour starts to be decomposed three
times, as before. The difference is that with longjmp (test_frame.txt), the
first attempt stops sooner. This might mean that the code is more efficient
with longjmp than without it. Possibly the difference could be removed by
adding this in a few more places in ftgrays.c:
#if FT_AVOID_LONGJMP
if ( ras.outline_decompose_error != 0 )
return ras.outline_decompose_error;
#endif
The difference between -fomit-frame-pointer and -fno-omit-frame-pointer seems
to be important, but maybe not. With GCC 4.5, it is currently making the
difference between crashing or not. With GCC 3.4.4, however, I *think* I
remember a version of the program crashing both with -fomit-frame-pointer and
with -fno-omit-frame-pointer. I've experimented with a lot of variations (such
as the optimization level, gcc versus g++, the glyph and its size, and making
the program as short as possible); at the moment I'm not able to produce a
crash with -fno-omit-frame-pointer.
One more thing: I suspected the longjmp crash might involve jump_buffer getting
corrupted by some accidental random memory access, so I surrounded the
jump_buffer with integers like this:
long alpha;
ft_jmp_buf jump_buffer;
long beta;
I initialized alpha and beta to 12345678 in gray_raster_reset, and confirmed
that their value was unchanged immediately before longjmp. On this basis it
seems less likely that jump_buffer is getting clobbered.
Any ideas?
Best wishes,
Tom
文林 Wenlin Institute, Inc. Software for Learning Chinese
E-mail: address@hidden Web: http://www.wenlin.com
Telephone: 1-877-4-WENLIN (1-877-493-6546)
☯