raceintospace / raceintospace

This is the GitHub home of Race Into Space, the computer version of the Liftoff! board game by Fritz Bronner. It was developed by Strategic Visions and published by Interplay as a disk-based game in 1993 and a CD-ROM in 1994. It was open-sourced in 2005 and a number of improvements have been made over the original.
GNU General Public License v2.0
170 stars 47 forks source link

Game crashes #200

Closed peyre closed 5 years ago

peyre commented 5 years ago

I compiled the latest version of the code and started a game. About halfway through (1967) it crashed after a mission. I had two missions scheduled and the game segfaulted after seeing the mission result screen. The stdout says simply "Segmentation fault (cord dumped)". I loaded the autosave and tried again. This time it got past that but crashed on the second mission. I restarted the game and loaded the autosave, then saved it and when I saved the game it crashed again. I've attached my autosave and the save I made. crash.zip

peyre commented 5 years ago

Thanks Ryan.  I thought about closing it myself but I wasn't certain the particular issue had been addressed.  I'm glad to see this one closed.

On Saturday, December 29, 2018, 10:08:57 PM PST, Ryan Yoakum <notifications@github.com> wrote:  

Closed #200 via #205.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

rnyoakum commented 5 years ago

I only got the fix committed last night. There had been a problem with the build, where one of the dependencies (PhysFS) was inaccessible. It wasn't connected to any of the other problems I've dealt with, and is probably the cause of the other late-game crash you mentioned to me. When I committed the fix, it automatically closed the issue by the power of Github - which I didn't expect - so I'd like to use this space to explain it more fully.

There was a variable - int pAry[15] - which had been used to track each of the successful mission steps in which a Prestige event occurred. This happened regardless of whether the event was a first or not, presumably so the prestige total could be calculated later. However, 1) the variable was defunct and no longer checked anywhere, and 2) was too small to account for all mission steps with associated prestige. Because the variable didn't have any access controls, once 16 steps were recorded it started overrunning the allocated memory and overwriting other variables in memory, specifically MANNED[2].

MANNED tracks the number of astro/cosmonauts on a mission. In the file you provided, the USSR was launching a three-person mission, which was recorded in MANNED. But during the mission execution, pAry would overflow and overwrite that value. At the end of the mission, the cosmonaut status would be updated in a for... loop, using the value in MANNED as the limit. But instead of 3, the limit was now around 15 or 19. When the game tried to access the pointer to a bogus 11th cosmonaut on the mission, it triggered a segmentation fault.

As best I could tell, pAry was one of several truly defunct variables no longer used, so I deleted all references to it and its index, pCnt. That should fix the problem.

peyre commented 5 years ago

Wow! That's quite in-depth. I'm glad you're on top of things like this. We should be approaching a point where the game's as good as it was running the old CVS code.