The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: z9999 on December 20, 2008, 07:03:42 AM

Title: [solved]r2173 - Crash when start Simutrans
Post by: z9999 on December 20, 2008, 07:03:42 AM
simutrans r2173 SDL, GDI

When starting simutrans, it crashed.

How to reproduce:
1. Strart Simutrans with command line "-log 1 -debug 4".
2. Change language to Japanese.
3. Quit Simutrans.
4. Strart Simutrans with command line "-log 1 -debug 4".

Result:
Crash.

Note:
If I remove "simuconf.close();" on simmain.cc line:366, simutrans don't crash.
This is the reason I rewrite the patch. But I can't understand why this causes crash with my poor c++ skill.


Message: create_win(): ins_win=0
Message: create_win(): new ins_win=1
Message: toolbar_t::init(): ID=32768d
Message: karte_t::reset_timer(): called
Message: karte_t::reset_timer(): called



sim.exe caused an Access Violation at location 005a9d78 in module sim.exe Reading from location 02303c8d.

Registers:
eax=022fb260 ebx=00f80000 ecx=000000f0 edx=00008a2d esi=00000000 edi=00000000
eip=005a9d78 esp=0023ea50 ebp=0023fa18 iopl=0         nv up ei pl nz na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000206

Call stack:
005A9D78  sim.exe:005A9D78  display_calc_proportional_string_len_width(char const*, int)  simgraph16.cc:2477
...
iUnicode = utf8_to_utf16((utf8 const*)text + iLen, &iLen);
if (iUnicode == 0) return width;
> w = fnt->screen_width[iUnicode];
if (w == 0) {
// default width for missing characters
...

005ADDC3  sim.exe:005ADDC3  WinMain  simsys_w16.cc:756
00401247  sim.exe:00401247
00401298  sim.exe:00401298
7C817067  kernel32.dll:7C817067  RegisterWaitForInputIdle

Title: Re: r2173 - Crash when start Simutrans
Post by: prissi on December 20, 2008, 10:24:46 PM
Because parsing does already a closing. Did not crash on my machine. Thank you.
Title: Re: r2173 - Crash when start Simutrans
Post by: z9999 on December 21, 2008, 07:30:06 AM
Unfortunately, r2174 still cause crash.

I wrote "line:366" but you deleted "line:395".
This doesn't solve the problem.
Sorry, I should have attached a patch.

I attached a patch.
Could you please change this ?
Title: Re: r2173 - Crash when start Simutrans
Post by: Dwachs on December 21, 2008, 09:55:24 AM
for me, deleting setting.xml did circumvent the crash at startup (while the bar says 'loading map')
Title: Re: r2173 - Crash when start Simutrans
Post by: prissi on December 21, 2008, 11:51:34 PM
Without the first closing, I cold not parse it. Investigating.
Title: Re: r2173 - Crash when start Simutrans
Post by: z9999 on December 22, 2008, 11:56:39 AM
In r2178, it still crash when starting.

Quote from: z9999 on December 20, 2008, 07:03:42 AM
How to reproduce:
1. Strart Simutrans with command line "-log 1 -debug 4".
2. Change language to Japanese.
3. Click "Quit" button on new map window and quit Simutrans.
4. Strart Simutrans with command line "-log 1 -debug 4".

I don't know this is gcc problem or not.
Can someone confirm this problem on linux or with MSVC ?
Title: Re: r2173 - Crash when start Simutrans
Post by: wernieman on December 22, 2008, 11:01:15 PM
But when you kill the settings.xml it works again?
Title: Re: r2173 - Crash when start Simutrans
Post by: z9999 on December 23, 2008, 11:24:24 AM
Thank you.

Quote from: wernieman on December 22, 2008, 11:01:15 PM
But when you kill the settings.xml it works again?

Yes. But that is not a solution, because that is the problem itself.
If we use both unicode language and debug mode at the same time, it crashes at startup.
So, I can't use debug mode.
Title: Re: r2173 - Crash when start Simutrans
Post by: prissi on December 23, 2008, 05:54:50 PM
What about 82 relase?
Title: Re: r2173 - Crash when start Simutrans
Post by: z9999 on December 24, 2008, 05:53:40 AM
Quote from: prissi on December 23, 2008, 05:54:50 PM
What about 82 relase?

Unfortunately, it still causes a crash, but thanks for your trying.
Title: Re: r2173 - Crash when start Simutrans
Post by: z9999 on December 25, 2008, 03:25:12 PM
I don't know who is breaking memories, but I heard some different reports.
Someone said that crash happened on starting simutrans without debug option.
And someone said that AI and Japanese language caused crash, but AI and English language didn't cause crash.
But currently I can't reprodece them.


[edit]
I don't know well but, the position of "sprachengui_t::init_font_from_lang();" on simmain.cc is too late, isn't it ?
So, it might fail to draw city name lavel and status bar message in Japanese in some cases - busy or slow performance.

In old versions, user interface was Englsh until I click the screen and open new map window.
But in this version, user interface and city name are Japanese when opened.

So, it should be done before drawing.


[edit]
Patch attached.
I don't know this is the best position or not.
But at least, "Init map ..." and "Loading map ..." for demo.sve is shown in Japanese and didn't crash for me.
Title: Re: r2173 - Crash when start Simutrans
Post by: prissi on December 25, 2008, 08:50:49 PM
WHile it still does not crash on my system, now init new map message in japanese is shown. Seems the correct way.
Title: Re: r2173 - Crash when start Simutrans
Post by: z9999 on December 26, 2008, 07:23:40 AM
Thank you.
Unfortunately, I still have some problems as the same reason.

1. When I start as "Japanese" and change language to "Polski", simutrans crash.
2. When I start as "English" and change language to "Polski", some controll button texts shows at wrong position.

So, I will continue to testing for this.


[edit]
When I replaced "text/pl.tab" to old none-utf8 version's file, simutrans didn't have these problems.
But uft8 version of "text/pl.tab" causes these problems.

So, problems always happens with "w = fnt->screen_width[iUnicode];".
This sometimes reads from wrong places.
Title: Re: r2173 - Crash when start Simutrans
Post by: prissi on December 26, 2008, 05:43:04 PM
Polski has prop-latin.fnt but is unicode encoding: This cannot work of course, since fnt have only 256 letters. This is a complete unrelated problem, though.
Title: [solved]r2173 - Crash when start Simutrans
Post by: z9999 on December 27, 2008, 02:14:49 AM
Thank you. Then eolved.