[1.1.80] Save file corruption on operating system crash

Anything that prevents you from playing the game properly. Do you have issues playing for the game, downloading it or successfully running it on your computer? Let us know here.
Post Reply
Switcher66
Manual Inserter
Manual Inserter
Posts: 1
Joined: Fri Jul 14, 2023 9:25 pm
Contact:

[1.1.80] Save file corruption on operating system crash

Post by Switcher66 »

I have noticed this happening for a while across multiple versions and just tried forcing it in the new 1.1.80 release and its still happening. After saving a map and exiting to the main menu, if the OS then crashes, the save file will become corrupted. In my case this occurs because im on a laptop with no battery and it will occasionally get unplugged while it is unused and in sleep mode.

Steps to reproduce:
1) start a new map
2) save the map and then exit to the main menu
3) turn off power to your computer/laptop
4) repower, reboot and reload factorio
5) observe corrupted file.

I have looked at the corrupted files in HxD and after a certain point all bytes are just zero. It is as though the map is not finished saving/writing to disk. Is there some soft-save feature where the game is still being written to disk in the background. I would expect that when the game says that the save is complete, then it is actually complete. To counter this I have been double-saving the game (*_A and *_B) within seconds of each other and it is only ever the second (*_B) save that gets corrupt.

I have attached two instances of this occuring: "Test_1" is a brand new unmodded map following the procedure above, and "Spaceblock B" is a modded map where the same thing has occurred. First save goes to all-zero at byte 0x11A and the second save at 0x500000.

Note, I have tried crashing only factorio using task manager and the corruption did not occur.
Attachments
Spaceblock B.zip
(7.11 MiB) Downloaded 27 times
Test_1.zip
(2.67 MiB) Downloaded 27 times

Rseding91
Factorio Staff
Factorio Staff
Posts: 13242
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.80] Save file corruption on operating system crash

Post by Rseding91 »

When saving finishes Factorio is finished writing to disk and closes the file handle. At that point anything not written to disk is due to the disk write logic built into windows.

You can disable disk write caching on windows but you will get degraded performance. https://www.thewindowsclub.com/enable-d ... indows-7-8

The fix is not have the operating system crash. An improper shutdown can cause this kind of issue across anything recently written to disk on any application.
If you want to get ahold of me I'm almost always on Discord.

User avatar
TheKillerChicken
Long Handed Inserter
Long Handed Inserter
Posts: 70
Joined: Sat Mar 02, 2019 7:06 am
Contact:

Re: [1.1.80] Save file corruption on operating system crash

Post by TheKillerChicken »

I know this is a necro: But should never have write-cache enabled on windows because as of windows 8, the kernel was changed and if there was any freeze or crash (BSOD), not only the OS could corrupt, but anything relevant to writing to disk/ssd/vvme. Write-caching works by storing the to-be written data in the system memory, which is considered volatile due to not having any means of battery backup, so if the OS crashes/freezes, corruption will occur, even the user account is prone to corrupting. So yea, I suggest disabling write-caching on the windows drive. I have write-caching disabled on my OS SSD for these reasons. If your OS is crashing, you should investigate what is the cause, and attempt to fix it as there is a serious hardware/software conflicts or issues happening there. If you use Windows 11, that could be the culprit as to my experience, it is as buggy as Vista was.

Post Reply

Return to “Technical Help”