[Bug 27398] Debug4x: Application locks/crashes at start due to bad symbol font handling (failed default charset/map selection)

wine-bugs at winehq.org wine-bugs at winehq.org
Sun Jun 5 13:15:09 CDT 2011


http://bugs.winehq.org/show_bug.cgi?id=27398

Anastasius Focht <focht at gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |download
             Status|UNCONFIRMED                 |NEW
                URL|                            |http://www.debug4x.com/
                 CC|                            |focht at gmx.net
          Component|-unknown                    |gdi32
            Summary|Debug4x: Application locks  |Debug4x: Application
                   |at start                    |locks/crashes at start due
                   |                            |to bad symbol font handling
                   |                            |(failed default charset/map
                   |                            |selection)
     Ever Confirmed|0                           |1

--- Comment #2 from Anastasius Focht <focht at gmx.net> 2011-06-05 13:15:08 CDT ---
Hello,

the problem seems to be the default charset/map handling for a symbol font
"HP48" the application installs and uses at runtime.

--- snip ---
...
0021:trace:font:WineEngCreateFontInstance L"HP48", h=-13, it=0, weight=400,
PandF=00, charset=1 orient 0 escapement 0
0021:trace:font:WineEngCreateFontInstance DC transform 1.000000 0.000000
0.000000 1.000000
0021:trace:font:WineEngCreateFontInstance not in cache
0021:trace:font:WineEngCreateFontInstance (it=0, bd=0) is selected for (it=0,
bd=0)
0021:trace:font:WineEngCreateFontInstance Chosen: L"HP48" L"Regular"
(/home/focht/.wine/dosdevices/c:/windows/Fonts/HP48.TTF/(nil):0)
0021:trace:font:WineEngCreateFontInstance font scale y: 1.000000
0021:trace:font:OpenFontFace
"/home/focht/.wine/dosdevices/c:/windows/Fonts/HP48.TTF"/(nil), 0, 0 x -13
0021:trace:font:WineEngGetFontData font=0x1b29b8, table=VDMX, offset=0x0,
buf=0x32f1f6, cbData=0x6
0021:trace:font:WineEngGetFontData Can't find table VDMX
0021:trace:font:OpenFontFace height -13 => ppem 13
0021:trace:font:WineEngCreateFontInstance caching: gdiFont=0x1b29b8 
hfont=0x4ccc
0021:trace:font:X11DRV_SelectFont hdc=0xabc, hfont=0x4ccc
0021:trace:font:X11DRV_SelectFont gdiFont = 0x1b29b8
0021:trace:font:update_font_code_page charset 0 => cp 1252
0021:Ret  gdi32.SelectObject() retval=0000007c ret=004b3a9b
0021:Call gdi32.GetFontLanguageInfo(00000abc) ret=004b3aa3
0021:Ret  gdi32.GetFontLanguageInfo() retval=00000000 ret=004b3aa3
0021:Call gdi32.SelectObject(00000abc,0000007c) ret=004b3ab2 
...
0021:trace:font:WineEngCreateFontInstance L"HP48", h=-13, it=0, weight=400,
PandF=00, charset=1 orient 0 escapement 0
0021:trace:font:WineEngCreateFontInstance DC transform 1.000000 0.000000
0.000000 1.000000
0021:trace:font:WineEngCreateFontInstance returning cached gdiFont(0x1b29b8)
for hFont 0x4cd0
0021:trace:font:X11DRV_SelectFont hdc=0xabc, hfont=0x4cd0
0021:trace:font:X11DRV_SelectFont gdiFont = 0x1b29b8
0021:trace:font:update_font_code_page charset 0 => cp 1252
0021:Ret  gdi32.SelectObject() retval=0000007c ret=004b4324
0021:Call gdi32.GetTextMetricsA(00000abc,0032f658) ret=004b3e56
0021:trace:font:WineEngGetOutlineTextMetrics font=0x1b29b8
0021:trace:font:WineEngGetOutlineTextMetrics OS/2 winA = 899 winD = 196 typoA =
613 typoD = -188 typoLG = 100 FT_Face a = 899, d = -196, h = 1150: HORZ a =
899, d = -196 lg = 55 maxY = 899 minY = -196
0021:trace:font:GetTextMetricsW text metrics:
    Weight = 400     FirstChar = 0     AveCharWidth = 8
    Italic =   0     LastChar = 61695         MaxCharWidth = 14
    UnderLined = 0     DefaultChar = 31     Overhang = 0
    StruckOut = 0     BreakChar = 32     CharSet = 0
    PitchAndFamily = 36
    --------------------
    InternalLeading = 1
    Ascent = 12
    Descent = 3
    Height = 15
0021:Ret  gdi32.GetTextMetricsA() retval=00000001 ret=004b3e56
0021:Call gdi32.GetCharABCWidthsA(00000abc,0000004d,0000004d,0032f64c)
ret=004b3e64
0021:trace:font:FONT_mbtowc mapped "M" -> L"M"
0021:trace:font:WineEngGetCharABCWidths 0x1b29b8, 77, 77, 0x32f64c
0021:trace:seh:raise_exception code=c0000005 flags=0 addr=0x6878c821
ip=6878c821 tid=0021
0021:trace:seh:raise_exception  info[0]=00000000
0021:trace:seh:raise_exception  info[1]=00000004
0021:trace:seh:raise_exception  eax=00000000 ebx=687c4ff4 ecx=00000000
edx=001b29b8 esi=0032f630 edi=0032f5b0
0021:trace:seh:raise_exception  ebp=0032f468 esp=0032f420 cs=0073 ds=007b
es=007b fs=0033 gs=003b flags=00010202
0021:trace:seh:call_vectored_handlers calling handler at 0x68f79bdc
code=c0000005 flags=0
0021:trace:seh:call_vectored_handlers handler at 0x68f79bdc returned 0 
...
*boom*
--- snip ---

An unhandled failure to select default charmap when the font was initialized
leads to a later crash when font->ft_face->charmap is accessed.

Code:
http://source.winehq.org/git/wine.git/blob/e6d6fbf6e94282f7063ab3d50bdc8b90a4b88a0f:/dlls/gdi32/freetype.c#l4554

Winedbg:

--- snip ---
Wine-dbg>
0x7b463818 get_glyph_index+0x12
[/opt/projects/wine/wine-git/dlls/gdi32/freetype.c:4558] in gdi32: movl   
0x8(%ebp),%eax
4558        if(font->ft_face->charmap->encoding == FT_ENCODING_NONE) {
Wine-dbg>bt
Backtrace:
=>0 0x7b463818 get_glyph_index+0x12(font=0x19f810, glyph=0x4d)
[/opt/projects/wine/wine-git/dlls/gdi32/freetype.c:4558] in gdi32 (0x0033f4e8)
  1 0x7b467fe1 get_glyph_index_linked+0x38(font=0x19f810, c=0x4d,
linked_font=0x33f564, glyph=0x33f568)
[/opt/projects/wine/wine-git/dlls/gdi32/freetype.c:5928] in gdi32 (0x0033f518)
  2 0x7b4682c2 WineEngGetCharABCWidths+0xd3(font=0x19f810, firstChar=0x4d,
lastChar=0x4d, buffer=0x33f64c)
[/opt/projects/wine/wine-git/dlls/gdi32/freetype.c:5999] in gdi32 (0x0033f588)
  3 0x7b4524ae GetCharABCWidthsW+0x84(hdc=0xabc, firstChar=0x4d, lastChar=0x4d,
abc=0x33f64c) [/opt/projects/wine/wine-git/dlls/gdi32/font.c:2426] in gdi32
(0x0033f5c8)
  4 0x7b4523a2 GetCharABCWidthsA+0xf0(hdc=0xabc, firstChar=0x4d, lastChar=0x4d,
abc=0x33f64c) [/opt/projects/wine/wine-git/dlls/gdi32/font.c:2377] in gdi32
(0x0033f618)
  5 0x004b3e64 in debug4x (+0xb3e63) (0x0033f69c)
  6 0x004b435f in debug4x (+0xb435e) (0x004b3870)
  7 0x004b410c in debug4x (+0xb410b) (0x004b4084)
  8 0x7500087b (0x83d88b53)
--- snip ---

Relevant data structures at this point:

--- snip ---
Wine-dbg>p *font
{entry={next=0x19e500, prev=0x7b49fd60}, gm=0x19e2f8, gmsize=0x1,
hfontlist={next=0x1a0be0, prev=0x19cf30}, potm=0x1a0c28,
total_kern_pairs=0xffffffff, kern_pairs=(nil), child_fonts={next=0x19f834,
prev=0x19f834}, ft_face=0x7d103da8, mapping=0x1a0b20, name="HP48", charset=0,
codepage=0x4e4, fake_italic=0, fake_bold=0, underline=0, strikeout=0,
orientation=0, font_desc={hash=0xfe97fe1f, lf={lfHeight=0xfffffff3, lfWidth=0,
lfEscapement=0, lfOrientation=0, lfWeight=0x190, lfItalic=0, lfUnderline=0,
lfStrikeOut=0, lfCharSet=1, lfOutPrecision=0, lfClipPrecision=0, lfQuality=0,
lfPitchAndFamily=0, lfFaceName={0x48, 0x50, 0x34, 0x38, 0, 0x7ffd, 0x4e4, 0,
0x3, 0, 0x7, 0, 0x4, 0, 0x8d04, 0x7ffd, 0x8c00, 0x7ffd, 0x8d04, 0x7ffd, 0x8c00,
0x7ffd, 0xf60c, 0x33, 0x2d5e, 0x40, 0x4, 0, 0x5070, 0xa6, 0xf638, 0}},
matrix={eM11=1.000000, eM12=0.000000, eM21=0.000000, eM22=1.000000},
can_use_bitmap=0x2000}, aveWidth=0, ppem=0xd, scale_y=1.000000, yMax=0, yMin=0,
ntmFlags=0x40, fs={fsUsb={0, 0, 0, 0}, fsCsb={0x1, 0}}, base_font=(nil),
GSUB_Table=0x0(nil), cache_num=0x22}

Wine-dbg>p *font->ft_face
{num_faces=0x1, face_index=0, face_flags=0xa1d, style_flags=0,
num_glyphs=0x101, family_name="HP48", style_name="Regular", num_fixed_sizes=0,
available_sizes=(nil), num_charmaps=0x1, charmaps=0x7d040160,
generic={data=0x0(nil), finalizer=(nil)}, bbox={xMin=0xffffffeb,
yMin=0xffffff3c, xMax=0x411, yMax=0x383}, units_per_EM=0x3e8, ascender=0x383,
descender=0xffffff3c, height=0x47e, max_advance_width=0x312,
max_advance_height=0x47e, underline_position=0xffffff04,
underline_thickness=0x29, glyph=0x7d104700, size=0x7d104810, charmap=(nil),
driver=0x7d01c208, memory=0x7d016970, stream=0x7d104b00,
sizes_list={head=0x7d03ffb0, tail=0x7d03ffb0}, autohint={data=0x0(nil),
finalizer=(nil)}, extensions=0x0(nil), internal=0x7d1040e8}

Wine-dbg>p *font->ft_face->charmaps[0]
{face=0x7d103da8, encoding=FT_ENCODING_MS_SYMBOL, platform_id=0x3,
encoding_id=0}
--- snip ---

The font provides a charmap with encoding -> FT_ENCODING_MS_SYMBOL but this
fails to get selected in first place.

lf.lfCharSet -> 1 (DEFAULT_CHARSET)
charset -> 0 (ANSI_CHARSET)

http://source.winehq.org/git/wine.git/blob/e6d6fbf6e94282f7063ab3d50bdc8b90a4b88a0f:/dlls/gdi32/freetype.c#l3839

--- snip ---
3839     ret->ft_face = OpenFontFace(ret, face, width, height);
3840 
3841     if (!ret->ft_face)
3842     {
3843         free_font( ret );
3844         LeaveCriticalSection( &freetype_cs );
3845         return 0;
3846     }
3847 
3848     ret->ntmFlags = face->ntmFlags;
3849 
3850     if (ret->charset == SYMBOL_CHARSET &&
3851         select_charmap(ret->ft_face, FT_ENCODING_MS_SYMBOL)) {
3852         /* No ops */
3853     }
3854     else if (select_charmap(ret->ft_face, FT_ENCODING_UNICODE)) {
3855         /* No ops */
3856     }
3857     else {
3858         select_charmap(ret->ft_face, FT_ENCODING_APPLE_ROMAN);
3859     }
--- snip ---

Failure of "else" select_charmap() is not handled, leading to a loophole of
having no default selected at all.

Maybe if everything fails, the first available charmap (with encoding != 0) in
the font's list should be selected as ultimate fallback (face->num_charmaps > 0
-> use face->charmaps[x] if encoding != 0).

$ sha1sum Debug4x_b159.exe 
6861e2b45b7468984236882cc03c7e73a5762ba1  Debug4x_b159.exe

$ wine --version
wine-1.3.21-159-ge398b93


--- quote ---
That's all the output I've been able to extract from running winedbg. My
attempts to "attach" to the pid of Debug4x to obtain a more complete backtrace
failed  due to the fact that "attach" is not a recognized command, despite what
http://wiki.winehq.org/Backtraces?action=show&redirect=winedbg says.
--- quote ---

That's because winedbg is already (automatically) attached at this point but
doesn't get any useful info due to nested exceptions (delphi exception handling
braindamage).

Regards

-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
Do not reply to this email, post in Bugzilla using the
above URL to reply.
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the wine-bugs mailing list