Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: WHat causes the Crash during Elections ?  (Read 968 times)

Purple Gorilla

  • Bay Watcher
    • View Profile
WHat causes the Crash during Elections ?
« on: October 04, 2014, 05:45:16 pm »

In the "stabile" release, it may happen, that game crashes during elections. Why does this happen ?

After looking at POLITICS.CPP, the line 575 looks suspicious, as it accesses the array canlaw[] without verifying, that its size is nonzero. The algorithm from lines 561 to 565 may produce this result, if all priorities are zero. The acces, to an uninitialized memory location in canlaw[] may read a value, that is out of range in the law array (assuming int is 32bit VERY MUCH out of range). The actual change of the law then causes acces out of the array with the laws. Appearendly, the C-compiler inserts a BOUND instruction before accesing the array, that results in the processor generated interrupt number 5, that has no handler inside LCS and is intecepted by the operation system.

If this assumtion were true, the following questions rise :
* Why does it happen so deterministic ? If you start the game again, the RND should return different values for the mood (lines 534-537), so it shouldn't happen, that it is unavoidable.
* Is it possible to change this in the single day, you have before the elections ? I tried, to raid a location and burn a flag, but it didn't work.
* Is it possible to avoid this by commiting certain actions on the days, before the elections (for example raiding the court hous to affect free speech ?)
* Is there a way, to see it coming from public opinion ? (for example people concerned about CCS terrorists, as there is no law about them)