Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Openttd got a floating point exception when selecting Chinese as its Language #5885

Closed
DorpsGek opened this issue Jan 29, 2014 · 12 comments
Closed
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

dehavilland opened the ticket and wrote:

When I select Chinese(either simplified or traditional) as its language, Openttd does not display it properly at first, then it crashes.

Crash log:

*** OpenTTD Crash Report ***

Crash at: Wed Jan 29 15:43:52 2014
In game date: 2051-05-09 (27)

Crash reason:
Signal: Floating point exception (8)
Message:

OpenTTD version:
Version: r26284 (0)
NewGRF ver: 140066ac
Bits: 64
Endian: little
Dedicated: no
Build date: Jan 28 2014 17:03:53

Stacktrace:
[00] openttd(_ZNK12CrashLogUnix13LogStacktraceEPcPKc+0x37) [0x704a67]
[01] openttd(_ZNK8CrashLog12FillCrashLogEPcPKc+0xeb) [0x5f9c4b]
[02] openttd(_ZNK8CrashLog12MakeCrashLogEv+0x48) [0x5f9e88]
[03] openttd() [0x704975]
[04] /usr/lib/libc.so.6(+0x353e0) [0x7fc72837d3e0]
[05] openttd(_Z18ShowDropDownListAtP6WindowPK21AutoDeleteSmallVectorIPK16DropDownListItemLj4EEii4Rect7Coloursbb+0x2ae) [0x83ceae]
[06] openttd(_Z16ShowDropDownListP6WindowPK21AutoDeleteSmallVectorIPK16DropDownListItemLj4EEiijbb+0x168) [0x83d258]
[07] openttd(_ZN17GameOptionsWindow7OnClickE5Pointii+0x273) [0x79c403]
[08] openttd(_Z17HandleMouseEventsv+0x124b) [0x842acb]
[09] openttd(_ZN15VideoDriver_SDL9PollEventEv+0x75) [0x826a65]
[10] openttd(_ZN15VideoDriver_SDL8MainLoopEv+0x80) [0x826db0]
[11] openttd(_Z12openttd_mainiPPc+0x13ec) [0x6f405c]
[12] /usr/lib/libc.so.6(__libc_start_main+0xf5) [0x7fc728369b05]
[13] openttd() [0x555d3a]

Operating system:
Name: Linux
Release: 3.13.0-2-ARCH
Version: # 1 SMP PREEMPT Mon Jan 27 10:25:23 CET 2014
Machine: x86_64
Compiler: GCC 4.8.2 "4.8.2 20131219 (prerelease)"

Configuration:
Blitter: 32bpp-sse4-anim
Graphics set: zBase (250)
Language: /usr/local/share/games/openttd/lang/traditional_chinese.lng
Music driver: extmidi
Music set: OpenMSX (96)
Network: no
Sound driver: sdl
Sound set: OpenSFX (87)
Video driver: sdl

Fonts:
Small: WenQuanYi Bitmap Song
Medium: WenQuanYi Bitmap Song
Large: WenQuanYi Bitmap Song
Mono: sprite

AI Configuration (local: 0):
0: Human

Libraries:
FontConfig: 2.11.0
FreeType: 2.5.2
ICU: 52.1
LZMA: 5.0.5
LZO: 2.06
PNG: 1.6.8
SDL: 1.2.15
Zlib: 1.2.8

---- gamelog start ----
Tick 62675: game loaded
Conversion from OTTD savegame without gamelog: version 4, 1
Revision text changed to r26284, savegame version 188, not modified, _openttd_newgrf_version = 0x140066ac
New game mode: 0 landscape: 1
---- gamelog end ----

*** End of OpenTTD Crash Report ***

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/5885
@DorpsGek
Copy link
Member Author

fonsinchen wrote:

In which order did you change the languages and what does it look like in between. From the picture and the stack trace I guess it crashes when you click on the dropdown to change the language a second time. As the window is so small I further guess that the font is assumed to have a height of 0 for some reason. That may lead to a division by 0 in dropdown.cpp either in line 376 or in line 377. That, of course, is quite speculative.

Could you maybe apply the attached patch and see if it still crashes? If it doesn't that would be an indication in favour of the above theory.

Unfortunately I can't reproduce the crash, even with the same font, probably because I have different version of ICU here.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5885#comment12980

@DorpsGek
Copy link
Member Author

dehavilland wrote:

Well I applied the patch and run again, it doesn't work :(
Yes it is the second time I try to click on the dropdown menu.

*** OpenTTD Crash Report ***

Crash at: Wed Jan 29 22:06:23 2014
In game date: 2051-05-09 (27)

Crash reason:
Signal: Floating point exception (8)
Message:

OpenTTD version:
Version: r26286M (2)
NewGRF ver: 140066ae
Bits: 64
Endian: little
Dedicated: no
Build date: Jan 29 2014 17:04:46

Stacktrace:
[00] openttd(_ZNK12CrashLogUnix13LogStacktraceEPcPKc+0x37) [0x700e97]
[01] openttd(_ZNK8CrashLog12FillCrashLogEPcPKc+0xeb) [0x5f891b]
[02] openttd(_ZNK8CrashLog12MakeCrashLogEv+0x48) [0x5f8b58]
[03] openttd() [0x700da5]
[04] /usr/lib/libc.so.6(+0x353e0) [0x7f3bc91343e0]
[05] openttd(_Z18ShowDropDownListAtP6WindowPK21AutoDeleteSmallVectorIPK16DropDownListItemLj4EEii4Rect7Coloursbb+0x2ae) [0x834e3e]
[06] openttd(_Z16ShowDropDownListP6WindowPK21AutoDeleteSmallVectorIPK16DropDownListItemLj4EEiijbb+0x168) [0x8351e8]
[07] openttd(_ZN17GameOptionsWindow7OnClickE5Pointii+0x273) [0x795fc3]
[08] openttd(_Z17HandleMouseEventsv+0x126b) [0x83aa2b]
[09] openttd(_ZN15VideoDriver_SDL9PollEventEv+0x75) [0x81ed75]
[10] openttd(_ZN15VideoDriver_SDL8MainLoopEv+0x80) [0x81f0c0]
[11] openttd(_Z12openttd_mainiPPc+0x13ec) [0x6f07ac]
[12] /usr/lib/libc.so.6(__libc_start_main+0xf5) [0x7f3bc9120b05]
[13] openttd() [0x5550ca]

Operating system:
Name: Linux
Release: 3.13.0-2-ARCH
Version: # 1 SMP PREEMPT Mon Jan 27 10:25:23 CET 2014
Machine: x86_64
Compiler: GCC 4.8.2 "4.8.2 20131219 (prerelease)"

Configuration:
Blitter: 32bpp-sse4-anim
Graphics set: zBase (250)
Language: /usr/local/share/games/openttd/lang/simplified_chinese.lng
Music driver: extmidi
Music set: OpenMSX (96)
Network: no
Sound driver: sdl
Sound set: OpenSFX (87)
Video driver: sdl

Fonts:
Small: WenQuanYi Bitmap Song
Medium: WenQuanYi Bitmap Song
Large: WenQuanYi Bitmap Song
Mono: sprite

AI Configuration (local: 0):
0: Human

Libraries:
FontConfig: 2.11.0
FreeType: 2.5.2
ICU: 52.1
LZMA: 5.0.5
LZO: 2.06
PNG: 1.6.8
SDL: 1.2.15
Zlib: 1.2.8

---- gamelog start ----
Tick 62675: game loaded
Conversion from OTTD savegame without gamelog: version 4, 1
Revision text changed to r26286M, savegame version 188, modified, _openttd_newgrf_version = 0x140066ae
New game mode: 0 landscape: 1
---- gamelog end ----

*** End of OpenTTD Crash Report ***


This comment was imported from FlySpray: https://bugs.openttd.org/task/5885#comment12982

@DorpsGek
Copy link
Member Author

fonsinchen wrote:

Could you try to get a stacktrace with line numbers? You have to compile it with --enable-debug=3 and then run it in gdb. When it crashed do "bt" in gdb.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5885#comment12986

@DorpsGek
Copy link
Member Author

DorpsGek commented Feb 1, 2014

dehavilland wrote:

Program received signal SIGFPE, Arithmetic exception.
0x0000000000acbcc2 in DropdownWindow::DropdownWindow (this=0x21c52c0, parent=0x1cc0540, list=0x21c48c0, selected=1, button=6, instant_close=false, position=..., size=..., wi_colour=COLOUR_GREY,
scroll=false) at /home/highcheng/src/games/openttd/src/widgets/dropdown.cpp:144
144 this->vscroll->SetCapacity(size.height * (uint16)list->Length() / list_height);

(gdb) bt
# 0 0x0000000000acbcc2 in DropdownWindow::DropdownWindow (this=0x21c52c0, parent=0x1cc0540, list=0x21c48c0, selected=1, button=6, instant_close=false, position=..., size=...,
wi_colour=COLOUR_GREY, scroll=false) at /home/highcheng/src/games/openttd/src/widgets/dropdown.cpp:144
# 1 0x0000000000acb2a6 in ShowDropDownListAt (w=0x1cc0540, list=0x21c48c0, selected=1, button=6, wi_rect=..., wi_colour=COLOUR_GREY, auto_width=false, instant_close=false)
at /home/highcheng/src/games/openttd/src/widgets/dropdown.cpp:390
# 2 0x0000000000acb40f in ShowDropDownList (w=0x1cc0540, list=0x21c48c0, selected=1, button=6, width=0, auto_width=false, instant_close=false)
at /home/highcheng/src/games/openttd/src/widgets/dropdown.cpp:433
# 3 0x00000000009dfd42 in GameOptionsWindow::OnClick (this=0x1cc0540, pt=..., widget=6, click_count=1) at /home/highcheng/src/games/openttd/src/settings_gui.cpp:442
# 4 0x0000000000ace0fa in DispatchLeftClickEvent (w=0x1cc0540, x=406, y=65, click_count=1) at /home/highcheng/src/games/openttd/src/window.cpp:734
# 5 0x0000000000ad2fda in MouseLoop (click=MC_LEFT, mousewheel=0) at /home/highcheng/src/games/openttd/src/window.cpp:2823
# 6 0x0000000000ad3385 in HandleMouseEvents () at /home/highcheng/src/games/openttd/src/window.cpp:2912
# 7 0x0000000000aa70ee in VideoDriver_SDL::PollEvent (this=0x183a060) at /home/highcheng/src/games/openttd/src/video/sdl_v.cpp:584
# 8 0x0000000000aa74f7 in VideoDriver_SDL::MainLoop (this=0x183a060) at /home/highcheng/src/games/openttd/src/video/sdl_v.cpp:720
# 9 0x00000000008dd793 in openttd_main (argc=1, argv=0x7fffffffc658) at /home/highcheng/src/games/openttd/src/openttd.cpp:869
# 10 0x00000000008f4c3d in main (argc=1, argv=0x7fffffffc658) at /home/highcheng/src/games/openttd/src/os/unix/unix.cpp:275

NOTE:By further examine I have found that list_height may be 0.
(gdb) p list_height
$1 = 0


This comment was imported from FlySpray: https://bugs.openttd.org/task/5885#comment12987

@DorpsGek
Copy link
Member Author

DorpsGek commented Feb 1, 2014

dehavilland wrote:

Also, size.height is 0.
(gdb) p size.height
$2 = 0
(gdb) p list->Length()
$5 = 54


This comment was imported from FlySpray: https://bugs.openttd.org/task/5885#comment12988

@DorpsGek
Copy link
Member Author

DorpsGek commented Feb 1, 2014

fonsinchen wrote:

Seems I forgot one division. This patch should effectively protect the dropdown from 0-sized items. However, the base problem is that the item heights are 0 in the first place ...

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5885#comment12990

@DorpsGek
Copy link
Member Author

DorpsGek commented Feb 2, 2014

dehavilland wrote:

Yes..

When applied the new patch, it gots a SIGABRT, the gdb ouput is

openttd: /home/highcheng/src/games/openttd/src/ai/../widget_type.h:688: void Scrollbar::SetCapacity(int): Assertion `capacity > 0' failed


This comment was imported from FlySpray: https://bugs.openttd.org/task/5885#comment12998

@DorpsGek
Copy link
Member Author

DorpsGek commented Mar 2, 2014

fonsinchen wrote:

You seem to be running arch linux and you have a package named wqy-bitmapsong-beta installed, right? Can you tell me what version of that package is installed?


This comment was imported from FlySpray: https://bugs.openttd.org/task/5885#comment13125

@DorpsGek
Copy link
Member Author

DorpsGek commented Mar 2, 2014

fonsinchen wrote:

OK, after installing an arch linux in a VM I can reproduce it. It seems FT_Set_Pixel_Sizes() always returns FT_Err_Invalid_Pixel_Size on that font, no matter what size I pass it. We should either catch that after fontcache.cpp:287 or declare that version of freetype and/or the font as buggy and unsupported. Some things I've tried in gdb:

Breakpoint 7, FreeTypeFontCache::FreeTypeFontCache (this=0x181b210,
fs=FS_NORMAL, face=0x181abe0, pixels=10) at
/home/alve/trunk/src/fontcache.cpp:293
293 this->height = this->ascender - this->descender;
(gdb) p }this
A syntax error in expression, near `}this'.
(gdb) p this
$42 = { = {_vptr.FontCache = 0xb93310 <vtable for
FreeTypeFontCache+16>, static caches = {0x181b210, 0x17e5e60, 0x17e5ea0,
0x17e5ee0}, parent = 0x17e5e20,
fs = FS_NORMAL, height = 10, ascender = 0, descender = 0,
units_per_em = 0}, face = 0x181abe0,
font_tables = {<SmallVector<SmallPair<unsigned int, SmallPair<unsigned
long, void const
> >, 16u>> = {data = 0x0, items = 0, capacity = 0}, },
glyph_to_sprite = 0x0}
(gdb) p *this->face
$43 = {num_faces = 1, face_index = 0, face_flags = 146, style_flags = 2,
num_glyphs = 29864, family_name = 0x1820c40 "WenQuanYi Bitmap Song",
style_name = 0x1820c20 "Bold", num_fixed_sizes = 1, available_sizes =
0x1820c60, num_charmaps = 1, charmaps = 0x181afc0, generic = {data =
0x0, finalizer = 0x0},
bbox = {xMin = 0, yMin = 0, xMax = 0, yMax = 0}, units_per_EM = 0,
ascender = 0, descender = 0, height = 0, max_advance_width = 0,
max_advance_height = 0,
underline_position = 0, underline_thickness = 0, glyph = 0x181b000,
size = 0x181b190, charmap = 0x181af90, driver = 0x1820ba0, memory =
0x1816e40, stream = 0x1f77300,
sizes_list = {head = 0x181b1f0, tail = 0x181b1f0}, autohint = {data =
0x0, finalizer = 0x0}, extensions = 0x0, internal = 0x1819ca0}
(gdb) p this->face->size
$44 = (FT_Size) 0x181b190
(gdb) p }this->face->size
A syntax error in expression, near `}this->face->size'.
(gdb) p *this->face->size
$45 = {face = 0x181abe0, generic = {data = 0x0, finalizer = 0x0},
metrics = {x_ppem = 0, y_ppem = 0, x_scale = 0, y_scale = 0, ascender =
0, descender = 0, height = 0,
max_advance = 0}, internal = 0x0}
(gdb) p pixels
$46 = 10
(gdb) this->face->available_sizes
Undefined command: "this->face->available_sizes". Try "help".
(gdb) p this->face->available_sizes
$47 = (FT_Bitmap_Size *) 0x1820c60
(gdb) p *this->face->available_sizes
$48 = {height = 18, width = 12, size = 956, x_ppem = 960, y_ppem = 960}
(gdb) p this->face->num_fixed_sizes
$49 = 1
(gdb) FT_Set_Pixel_Sizes(this->face, 0, 18)
Undefined command: "FT_Set_Pixel_Sizes". Try "help".
(gdb) p FT_Set_Pixel_Sizes(this->face, 0, 18)
$50 = 23
(gdb) p *this->face
$51 = {num_faces = 1, face_index = 0, face_flags = 146, style_flags = 2,
num_glyphs = 29864, family_name = 0x1820c40 "WenQuanYi Bitmap Song",
style_name = 0x1820c20 "Bold", num_fixed_sizes = 1, available_sizes =
0x1820c60, num_charmaps = 1, charmaps = 0x181afc0, generic = {data =
0x0, finalizer = 0x0},
bbox = {xMin = 0, yMin = 0, xMax = 0, yMax = 0}, units_per_EM = 0,
ascender = 0, descender = 0, height = 0, max_advance_width = 0,
max_advance_height = 0,
underline_position = 0, underline_thickness = 0, glyph = 0x181b000,
size = 0x181b190, charmap = 0x181af90, driver = 0x1820ba0, memory =
0x1816e40, stream = 0x1f77300,
sizes_list = {head = 0x181b1f0, tail = 0x181b1f0}, autohint = {data =
0x0, finalizer = 0x0}, extensions = 0x0, internal = 0x1819ca0}
(gdb) p *this->face->height
Cannot access memory at address 0x0
(gdb) p *this->face->size
$52 = {face = 0x181abe0, generic = {data = 0x0, finalizer = 0x0},
metrics = {x_ppem = 0, y_ppem = 0, x_scale = 0, y_scale = 0, ascender =
0, descender = 0, height = 0,
max_advance = 0}, internal = 0x0}
(gdb) p FT_Err_Invalid_Pixel_Size
$53 = FT_Err_Invalid_Pixel_Size
(gdb) p (int)FT_Err_Invalid_Pixel_Size
$54 = 23
(gdb) p FT_Set_Pixel_Sizes(this->face, 12, 18)
$55 = 23
(gdb) p FT_Set_Pixel_Sizes(this->face, 0, 0)
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
$56 = 23
(gdb) p FT_Set_Pixel_Sizes(this->face, 0, 10)
$57 = 23
(gdb) p FT_Set_Pixel_Sizes(this->face, 0, 12)
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
$58 = 23
(gdb) p FT_Set_Pixel_Sizes(this->face, 0, 13)
$59 = 23
(gdb) p FT_Set_Pixel_Sizes(this->face, 0, 9)
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
$60 = 23
(gdb) p *this->face
$61 = {num_faces = 1, face_index = 0, face_flags = 146, style_flags = 2,
num_glyphs = 29864, family_name = 0x1820c40 "WenQuanYi Bitmap Song",
style_name = 0x1820c20 "Bold", num_fixed_sizes = 1, available_sizes =
0x1820c60, num_charmaps = 1, charmaps = 0x181afc0, generic = {data =
0x0, finalizer = 0x0},
bbox = {xMin = 0, yMin = 0, xMax = 0, yMax = 0}, units_per_EM = 0,
ascender = 0, descender = 0, height = 0, max_advance_width = 0,
max_advance_height = 0,
underline_position = 0, underline_thickness = 0, glyph = 0x181b000,
size = 0x181b190, charmap = 0x181af90, driver = 0x1820ba0, memory =
0x1816e40, stream = 0x1f77300,
sizes_list = {head = 0x181b1f0, tail = 0x181b1f0}, autohint = {data =
0x0, finalizer = 0x0}, extensions = 0x0, internal = 0x1819ca0}
(gdb) p *this->face->available_sizes
$62 = {height = 18, width = 12, size = 956, x_ppem = 960, y_ppem = 960}


This comment was imported from FlySpray: https://bugs.openttd.org/task/5885#comment13126

@DorpsGek
Copy link
Member Author

DorpsGek commented Mar 2, 2014

fonsinchen wrote:

We should just do FT_Select_Size (http://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html# FT_Select_Size) once we've figured out which size we want in fontcache.cpp:287. FT_Set_Pixel_Sizes does FT_Request_Size internally and apparently one cannot actually rely on it to select a size.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5885#comment13127

@DorpsGek
Copy link
Member Author

DorpsGek commented Mar 2, 2014

fonsinchen wrote:

ulfhermann/openttd@cf81b7d should do but needs some testing.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5885#comment13128

@DorpsGek
Copy link
Member Author

DorpsGek commented Mar 3, 2014

fonsinchen closed the ticket.

Reason for closing: Fixed

In r26389


This comment was imported from FlySpray: https://bugs.openttd.org/task/5885

@DorpsGek DorpsGek closed this as completed Mar 3, 2014
@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant