corrupted saved game: "string ended unexpectedly"

Bug #1654897 reported by king of nowhere
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
widelands
Fix Released
High
Unassigned

Bug Description

I got an error message when trying to open a saved game:

"economies: player 7: Stream ended unexpectedly (0 bytes read, 4 expected)"

and the save cannot be opened. the closer autosave is fine, luckily.

file attached.

Related branches

Revision history for this message
king of nowhere (lainluigi86) wrote :
Revision history for this message
SirVer (sirver) wrote :

I can confirm that the game does not load on my system either.

I unzipped the save and looked at the data sizes in the save file and they seem to be reasonable. I did not analyze the contents of the economy file yet, but I do not understand how the file could become faulty.

Could you attach the savegame that is close by too? I'd like to compare the file size and maybe I can trigger an invalid save with it somehow.

stdout: https://gist.github.com/SirVer/30b1cf558e489f3d539359da79c676ad
sizes: https://gist.github.com/SirVer/6c6bf7bf7a81e39a7c05fd86d48d74fe

Changed in widelands:
status: New → Incomplete
Revision history for this message
king of nowhere (lainluigi86) wrote :

that's the closer autosave, some 20 minutes before the faulty one. Restarting from the autosave, i kept playing for another couple hours and the saved games I made further worked correctly

SirVer (sirver)
Changed in widelands:
importance: Undecided → Medium
Revision history for this message
SirVer (sirver) wrote :

I investigated the two saves and can conclude that the problem is the following:

When the problematic game was saved, player 1 had 34 economies - at least 34 economies of player one seem to be saved into the file. When the game is loaded, the Player class owns 35 economies. The code happily loaded as the 35th economy the first economy of player 2 that was saved. In the end, the loader ran out of economies for player 7.

As of now I do not know why there have been more economies on load then on save. I suggested the attached branch for merge. It detects if there are a different amount of economies on save or load and crashes on load, maybe giving us an opportunity to catch this earlier.

king: I think your particular game is a strong test case because of many ships and many economies. Could you continue playing it once this is merged and update this bug with crashing savegames?

Revision history for this message
king of nowhere (lainluigi86) wrote :

"Could you continue playing it once this is merged and update this bug with crashing savegames?"

that one is a challenge map I've been working on and off for over a year trying to find a right balance. So yes, I will keep playing it.

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for widelands because there has been no activity for 60 days.]

Changed in widelands:
status: Incomplete → Expired
GunChleoc (gunchleoc)
Changed in widelands:
status: Expired → Incomplete
Changed in widelands:
status: Incomplete → Expired
Revision history for this message
GunChleoc (gunchleoc) wrote :

Also reported in https://bugs.launchpad.net/widelands/+bug/1735954 with an attached savegame

Changed in widelands:
status: Expired → Confirmed
importance: Medium → High
milestone: none → build20-rc1
Revision history for this message
Manfred (manphi) wrote :

Is there any solution for the corrupted savegames? I've been playing for several hours on a huge map and got this error on a savegame. I first ignored it because I thought maybe it will not effect any future saves, but it did. And now i would have to play about 8 hours since my last uncurrupted savegame.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I have no idea how to fix an already corrupted savegame - those packets are written in a binary format, so it would be really tough.

I am working on a branch that will hopefully fix the issue, but it will make old savegames incompatible too.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I thought that keeping flags from doing road-related things in the constructor during saveloading might fix it - it doesn't.

Revision history for this message
GunChleoc (gunchleoc) wrote :
Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

This branchs reworks handling of economies and contains some more assertions:
https://code.launchpad.net/~widelands-dev/widelands/bug-1732765-economy-refactoring/+merge/345277

Unluckily it will break savegame compatibility.
So we mave to close this bug, without proved fixed.

GunChleoc (gunchleoc)
Changed in widelands:
status: Confirmed → Fix Committed
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build20-rc1

Changed in widelands:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.