The International Simutrans Forum

Simutrans Extended => Simutrans-Extended development => Topic started by: fbfree on September 25, 2011, 10:23:28 PM

Title: Bug - Crash on cancelling replace
Post by: fbfree on September 25, 2011, 10:23:28 PM
In the savegame http://simutrans-germany.com/files/upload/NZ1856.sve (http://simutrans-germany.com/files/upload/NZ1856.sve), convoy 221 is the last convoy to be replaced on the route.  If one clicks the 'replace' button for this convoy and clicks 'clear', the replace button on the convoy information screen remains depressed when in any other game I've started it pops back up, cancelling the replace cycle.  If I close the replace dialogue and click the replace button again, the program crashes.  The replace occurs normally if I do nothing.

Initially, line (25) had 6 convoys in it, of which 'replace all' was selected with a replace cycle of 1 replace and 1 skip.  Since that time, line (25)'s schedule had been modified, several other convoys from another line had been added to line (25), and some of line (25)'s convoys had been sent to the depot and upgraded manually.  I have not been able to reproduce this behaviour from a virgin map or the default game on loading, although I did not test the effects of changes to the line during the replace cycle.

This bug occurs in both experimental 9.12 and 10.1 for linux x386, using pak-brit-exp 0.8, and 1GB ram.
Title: Re: Bug - Crash on cancelling replace
Post by: jamespetts on September 25, 2011, 11:54:03 PM
You have managed to unearth a very obscure bug! I am not quite sure what causes it ultimately, but, somehow, the replace datum loses track of which convoys it is supposed to be replacing, so, when the datum is cleared, the convoy still thinks that it has a replace datum attached to it (hence the depressed button), and, when you go into it (by depressing the button), it crashes, as it is trying to read a memory location that has been deleted. I have fixed this now on my 10.x branch by checking whenever a player opens the replace dialogue that the convoy invoking it is indeed in the list of convoys, and adding it if it is not.

I expect that the cause is related to the fact that you had been tinkering with the convoys when the replace was in progress, although it would take for ever to work out how exactly, and this workaround seems to work effectively without side effects.

Thank you for your report!