The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: captain crunch on September 04, 2015, 11:32:32 PM

Title: r7572: core dump on pressing of unassigned key
Post by: captain crunch on September 04, 2015, 11:32:32 PM
Since r7572 simutrans dumps core when I press an unassigned key.
In previous versions the help window popped up to show which key does what.
Last line of debug log is:

Message: interaction_t::interactive_event():    Keyboard event with code 257 '?'
sim: boden/wege/weg.cc:98: static weg_t* weg_t::alloc(waytype_t): Assertion `0' failed.


Title: Re: r7572: core dump on pressing of unassigned key
Post by: Ters on September 05, 2015, 07:25:20 AM
I don't think you've pressed an unassigned key, because the only way I can see this crash is when a tool has been activated.

Most likely, this comes from tool_build_way_t::get_besch, which seems to have some dubious code. If wegbauer_t::get_besch() returns NULL, it then parses default_param as an integer representing a way type. Next it ands that number with 63, meaning that the number can be anything from 0 through 63. Then it indexes an array with the resulting number, but the array is only 17 elements long, so there is a risk of going out of bounds. If the array lookup returns NULL, it then tries to create a way of the particular way type (the unanded value) to see what gets created, then remembers that and deletes the way again. The crash probably happens because the way type (parsed from default_param) doesn't represent a valid way type, so that the attempt to create a way fails.
Title: Re: r7572: core dump on pressing of unassigned key
Post by: Dwachs on September 05, 2015, 07:49:52 AM
should be fixed with r7579, kind of duct-tape fix.
Title: Re: r7572: core dump on pressing of unassigned key
Post by: jamespetts on September 05, 2015, 09:28:31 AM
May I suggest a better fix for this as here (https://github.com/jamespetts/simutrans-experimental/commit/ae035fd40692859a066e63cd20c9ea92af342a4c)? This is my version of the fix from Experimental, but I believe that the relevant parts of the code are the same.
Title: Re: r7572: core dump on pressing of unassigned key
Post by: Dwachs on September 05, 2015, 10:49:34 AM
This is a fix to a different issue: the default way could be not available for time line games. Thanks for the reminder. I committed a fix in r7580