The International Simutrans Forum

Simutrans Extended => Simutrans-Extended bug reports => Simutrans-Extended development => Simutrans-Extended closed bug reports => Topic started by: Philip on September 10, 2013, 05:54:16 PM

Title: [11.x] segfault when max_alternative_destinations is 15
Post by: Philip on September 10, 2013, 05:54:16 PM
It seems we've got an off-by-one in simcity.cc:step_passagiere: when max_alternative_destinations is 15, max_destinations is 16, destination_count is sometimes 16, and destinations_assigned becomes 16 in the for loop, but is used as index into an array of size 16.  I think the attached patch fixes it, but it also reduces the number of destinations per passenger by one. Previously, we never created fewer than two destinations even if there should have been just one, so I think this was another bug that affected all games; the segfault only happened with max_alternative_destinations at its maximum value of 15.
Title: Re: [11.x] segfault when max_alternative_destinations is 15
Post by: jamespetts on September 10, 2013, 11:23:28 PM
Thank you very much for this - will apply when I have time (currently prioritising finishing working on a somewhat tricky feature/recalibration on the passenger-generation branch).

Interestingly, the passenger-generation branch refactors the code so as no longer to use this array and to lift the limit on max_alternative_destinations entirely, but the fix is still welcome for stabilising the 11.x branch until the next major release is ready.

Your bug spotting/reporting is much appreciated!
Title: Re: [11.x] segfault when max_alternative_destinations is 15
Post by: Philip on September 11, 2013, 08:02:44 PM
Thank you, I was hoping the reports wouldn't be too annoying. I'm looking forward to testing the passenger generation code, but I don't think it's quite all there yet? Anyway, would it help to send diffs based on the passenger-generation branch instead of the 11.x branch? Or is there anything else I could do to make it easier for you to apply them?

Thanks again!
Title: Re: [11.x] segfault when max_alternative_destinations is 15
Post by: jamespetts on September 11, 2013, 08:24:54 PM
Bug reports when accompanied by fixes are anything but annoying! Do feel free to post as many fixes for bugs as you are able/desirous to find.

For the time being, it is better to have bug fixes against the 11.x branch, as the next releases will be on the 11.x for the time being, but I want to finish a particular sub-project on the passenger-generation branch for the time being whilst my train of thought is (relatively) uninterrupted so that I can get that finished properly before turning back to bugs.

You are more than welcome to try out the partially completed passenger-generation branch so far, but do note that it is incomplete and that any game saved with a version of 12 will probably not be compatible with any release version. I am currently working on proper scaling of the quantities of passenger generation and demand, and working out how that scales as against population.
Title: Re: [11.x] segfault when max_alternative_destinations is 15
Post by: jamespetts on September 26, 2013, 11:22:48 PM
Quote from: Philip on September 10, 2013, 05:54:16 PM
It seems we've got an off-by-one in simcity.cc:step_passagiere: when max_alternative_destinations is 15, max_destinations is 16, destination_count is sometimes 16, and destinations_assigned becomes 16 in the for loop, but is used as index into an array of size 16.  I think the attached patch fixes it, but it also reduces the number of destinations per passenger by one. Previously, we never created fewer than two destinations even if there should have been just one, so I think this was another bug that affected all games; the segfault only happened with max_alternative_destinations at its maximum value of 15.

Now implemented on the 11.x branch - thank you for this!