Error Writing To Save File
Moderator: Oberlus
Forum rules
Always mention the exact version of FreeOrion you are testing.
When reporting an issue regarding the AI, if possible provide the relevant AI log file and a save game file that demonstrates the issue.
Always mention the exact version of FreeOrion you are testing.
When reporting an issue regarding the AI, if possible provide the relevant AI log file and a save game file that demonstrates the issue.
Error Writing To Save File
I have been getting an error when the program tries to autosave. I noticed this happens after 290 turns or more. I am running the latest version. 4.5 build 2016-01-11.609936e. I was having the same issue with the previous version was hoping it was fixed in this release.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: Error Writing To Save File
Edit: removed unnecessary discussion of XML vs. binary save settings /Edit
If you have a save that reproduces the problem, then please zip the save and post it in a reply if it can be attached (might not due to size limits).
If you can't do that, then please attach all the .log files from immediately after getting the error. Ideally load a game that produces the issue after a single turn, and delete all the logs before producing the error, to be sure you're getting only fresh log files.
The logs (and saves) are in the directory discussed here: http://freeorion.org/index.php/Config.xml
If you have a save that reproduces the problem, then please zip the save and post it in a reply if it can be attached (might not due to size limits).
If you can't do that, then please attach all the .log files from immediately after getting the error. Ideally load a game that produces the issue after a single turn, and delete all the logs before producing the error, to be sure you're getting only fresh log files.
The logs (and saves) are in the directory discussed here: http://freeorion.org/index.php/Config.xml
Re: Error Writing To Save File
The saved file and the log files when zipped where still too large to attach. You can download the zipped log file and game file from the links below.
http://newage-mkt.com/AI_8.zip
http://newage-mkt.com/FreeOrion_Save.zip
Thanks,
Keith
http://newage-mkt.com/AI_8.zip
http://newage-mkt.com/FreeOrion_Save.zip
Thanks,
Keith
Re: Error Writing To Save File
@knelson: What platform are you running on? What are your system specs?
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: Error Writing To Save File
I loaded the save with the latest master build, pressed turn, and it seemed to work fine. Ran a few more turns with turn autocycle on, and eventually got the error popup. In the server log, I seewhich is not especially helpful. I'm adding some extra logging now...
Edit: the preceeding line appears to be actually indicating where it's failing, which is when serializing the stat records... which is a bit surprising as that's just a nested bunch of std containers / data.
Edit2: The problem seems to occur when serializing to XML, and before the compression is attempted. I'm guessing / it seems like some limit or buffer being exhausted when writing too much data, which just happens to occur for this game when attempting to serialize the stat records.
I suggest: Before loading a game, go into the options screen, scroll to the far-right "Other" tab, and enable Binary Serialization. Then load the game and attempt to continue playing. This seems to more-reliably produce autosaves for me, without any errors popping up. The resulting saves won't be cross-platform compatible, but should work fine on your own system.
Code: Select all
2016-01-22 11:58:09.244977 [error] Server : SaveLoad.cpp:171 : Error when writing save file. SaveGame exception: : output stream error
Edit: the preceeding line appears to be actually indicating where it's failing, which is when serializing the stat records... which is a bit surprising as that's just a nested bunch of std containers / data.
Edit2: The problem seems to occur when serializing to XML, and before the compression is attempted. I'm guessing / it seems like some limit or buffer being exhausted when writing too much data, which just happens to occur for this game when attempting to serialize the stat records.
I suggest: Before loading a game, go into the options screen, scroll to the far-right "Other" tab, and enable Binary Serialization. Then load the game and attempt to continue playing. This seems to more-reliably produce autosaves for me, without any errors popping up. The resulting saves won't be cross-platform compatible, but should work fine on your own system.
Re: Error Writing To Save File
I am using a windows platform.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: Error Writing To Save File
I've moved the stringstream used for storing the XML serialization data onto the heap, instead of the stack, in the hope that this would also move the buffer, and added custom NVP-serialization name tags for meter current and initial values, in the hope of reducing the size of the serialized text. Doesn't seem to have helped, though.Geoff the Medio wrote:Edit2: The problem seems to occur when serializing to XML, and before the compression is attempted. I'm guessing / it seems like some limit or buffer being exhausted when writing too much data, which just happens to occur for this game when attempting to serialize the stat records.
I also somewhat randomly have errors reading in the save, due to "bad allocation" errors, when attempting to decompress the saved serialization text. Sometimes it happens, sometimes not, for no apparent reason. Rebuilding after making some code change seems to help sometimes.
I also put some debug log output to check the size of the stringstream into which save data is serialized, and it gets up to ~70 MB before the universe stuff is serialized, which is a bit surprisingly large, and supports the buffer limit theory. Haven't been able to find any way to pre-allocate a buffer for the stringstream, though.
Re: Error Writing To Save File
FYI, I have been occasionally getting these errors as well, always late game, but have never been able to reproduce them. I have auto save set to generate every turn, and reloading the previous turn's autosave has always worked, although sometimes freeorion needs to be restarted first.
Windows 10 64bit, AMD 8 Core, 16 GB
Nvidia GTX 670 @ 3240x1920
FreeOrion Build: Latest Windows Test Build
Nvidia GTX 670 @ 3240x1920
FreeOrion Build: Latest Windows Test Build
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: Error Writing To Save File
I tried replacing stringstream by an std::string wrapped using some boost iostreams wrappers: back_insert_device<std::string>, and stream<back_insert_device<std::string> >. This lets me manually reserve space to increase the buffer capacity, so as to avoid repeatedly reallocating more memory in order to store serialized text data as it is generated while saving.
This works fine for loading saves, but it inexplicably breaks when serializing to text in order to write a new save. If I look at the contents of the buffer after serializing, it suddenly stops mid-entry. This occurs even when serializing a small new game gamestate, so is seemingly not an issue with the buffer size, unless there's some other internal buffer I'm not aware of.
Edit: Eventually found that I needed to add calls to flush the stream to the buffer. After that, it seems to work. Try loading the save and playing again with the next test build.
This works fine for loading saves, but it inexplicably breaks when serializing to text in order to write a new save. If I look at the contents of the buffer after serializing, it suddenly stops mid-entry. This occurs even when serializing a small new game gamestate, so is seemingly not an issue with the buffer size, unless there's some other internal buffer I'm not aware of.
Edit: Eventually found that I needed to add calls to flush the stream to the buffer. After that, it seems to work. Try loading the save and playing again with the next test build.
Re: Error Writing To Save File
I just played a large game to a little over 400 turns without any save errors, and have had multiple games in the 250 - 300 turn range, also without any save errors, on the Feb 09 Build. I think you fixed it.
Windows 10 64bit, AMD 8 Core, 16 GB
Nvidia GTX 670 @ 3240x1920
FreeOrion Build: Latest Windows Test Build
Nvidia GTX 670 @ 3240x1920
FreeOrion Build: Latest Windows Test Build
Re: Error Writing To Save File
Sorry, but I dont think so...UrshMost wrote:I just played a large game to a little over 400 turns without any save errors, and have had multiple games in the 250 - 300 turn range, also without any save errors, on the Feb 09 Build. I think you fixed it.
O got the "Error when writing save file" today.
v0.4.5+ build 2016-06-06.4187172
Windows 7 ultlimate 64 SP1
8 GB RAM, i3-2100, game on C: SSD drive, savegame folder in D: conventional HD.
I also cannot save game thru the main menu. All save tries since turn 380 results on a empty file (size = 0)
Frustrating... a so big game wich I could win...
-
- Programmer
- Posts: 389
- Joined: Sun Feb 14, 2016 12:08 am
Re: Error Writing To Save File
If you were able to save before with the same build, is the drive full or read-only?
A couple of issues were fixed around the same time as your build, you might try a more recent build. Failing that, could you attach the freeorion.log and freeoriond.log files?
A couple of issues were fixed around the same time as your build, you might try a more recent build. Failing that, could you attach the freeorion.log and freeoriond.log files?
Any content posted should be considered licensed GNU GPL 2.0 and/or CC-BY-SA 3.0 as appropriate.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: Error Writing To Save File
When reporting such issues, the logs should be attached unless there's a reason not to.dbenage-cx wrote:...could you attach the freeorion.log and freeoriond.log files?
If you can find a previous save from the same game, which can be used to reproduce the issue, then attaching that (or more likely posting it somewhere else and linking, as it would presumably be too large a file for the forums), would be helpful.dariomor wrote:All save tries since turn 380 results on a empty file (size = 0)
Re: Error Writing To Save File
I don't know if this is related but I sometimes get blank 0Kb saves, and it's happened to me both on Windows and Linux, it's never happened to an autosave and only ever to a save I make just before shutting the game down.
I never notice it's happened until I reboot the game and try to load my last save, so log files aren't useful, I have now got the directory open so I can check the filesize and similar, screenshot attached. Due to absence of valid logs, not sure where to start looking, but as it happens on both my machines (I don't use the Windows laptop much for FO but it has happened there) it appears to be more than just a personal settings glitch.
I never notice it's happened until I reboot the game and try to load my last save, so log files aren't useful, I have now got the directory open so I can check the filesize and similar, screenshot attached. Due to absence of valid logs, not sure where to start looking, but as it happens on both my machines (I don't use the Windows laptop much for FO but it has happened there) it appears to be more than just a personal settings glitch.
Mat Bowles
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: Error Writing To Save File
If it's happening with 3 MB save files, it's not related to the previous issue with overly large universes.
A log or way to reproduce will be needed, though...
A log or way to reproduce will be needed, though...