News:

Simutrans Forum Archive
A complete record of the old Simutrans Forum.

[11.x] segfault when max_alternative_destinations is 15

Started by Philip, September 10, 2013, 05:54:16 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Philip

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.

jamespetts

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!
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Philip

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!

jamespetts

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.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

jamespetts

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!
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.