Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project destroyed on system crash #31578

Open
Skaruts opened this issue Aug 22, 2019 · 9 comments
Open

Project destroyed on system crash #31578

Skaruts opened this issue Aug 22, 2019 · 9 comments

Comments

@Skaruts
Copy link

Skaruts commented Aug 22, 2019

Godot 3.1.1.stable
Windows 7
ATI Radeon HD 4870
Intel Core 2 Duo E6400

My system crashed while editing a project, and now my project.godot, all my scenes (including an already forgotten tileset.tscn), and one of the scripts, are all like this:

0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
# repeated many more lines

The script that was detroyed was a tool script, so it's possible that this was related to it? My system crashes on occasion, but I never had a project destroyed by it. I also rarely use tool scripts, so I'm connecting the two things, though maybe they're not related. That script exported some vars and updated a Sprite2D and a CollisionPolygon2D in real time in the editor.

Nevermind that, it still happened more times while no using tool scripts.


EDIT: I didn't lose a lot from this. This happened in a prototype I started just a few hours ago. I only had 6 simple scenes. I just thought I ought to bring it up here, in case this is related to some obscure problem in Godot and there's something that can be done about it.

@bojidar-bg
Copy link
Contributor

Not sure if this is a Godot problem. I've had a drive unplugged badly, resulting in a list of Godot issues I had on it to look like so:
image

That being said, if there is something we might do to lessen the damage of such crashes without impacting performance much, it might be a good idea to do it.
(also, make backups / use a VCS, you never know when a crash or misbehavor by some program will happen)

@Skaruts
Copy link
Author

Skaruts commented Aug 22, 2019

Yea, I was about to edit the OP to say that I do use backups, but this happened in a prototype I was making since just a few hours ago. Not a lot was lost either. I only had 6 simple scenes in total. I just thought I ought to bring it up here, in case there's anything that can be done to prevent it from happening.

@Skaruts
Copy link
Author

Skaruts commented Sep 5, 2019

I realized this is a bigger problem than I had expected. Since my last post I had my project crash my system quite a few more times (still haven't figured out why -- Godot 2 never does it), and I just had a power outage a few minutes ago while working on another new project, and it too got almost entirely destroyed.

What I realized is that even if you're using backups this is still a problem: you're likely not committing changes every five minutes, and you might lose your incomplete or experimental progress (any progress that there's no reason to commit yet) of several hours, maybe even several days, because of this.

I only started using Godot 3 recently, and this never happened to me in Godot 2 (which I've been using since 2016). So as far as I can tell, this is something to do with how Godot 3 handles files. Seems as if Godot is keeping files open after reading/writing, or something of the sort. At least that's my best not-really-informed guess.

I never had this kind of thing happen in any other apps either, by the way.

@Skaruts
Copy link
Author

Skaruts commented Nov 12, 2019

Haven't been having these problems on 3.2 alpha 3 so far. No system crashes while using godot, and no corrupt files from the last power outage a few days ago. Maybe it got fixed. :)

EDIT: Still haven't had this issue ever again. Godot 3.2 rc4 is just out a few hours ago from me writing this. I haven't tried it yet, and I'm still on rc1 at the moment, but this issue really seems pretty much gone.

Not sure I should close this or leave it to someone else.

@Skaruts
Copy link
Author

Skaruts commented Dec 16, 2023

This just happened to me again now in Godot 4.2.stable.

Not so indifferent about the losses this time, but it could be worse. I'll have to spend an hour rewriting a whole script.

I may have found the cause of the issue, though: I had pressed Ctrl-S the moment before the lights went out, and I think it may have happened just as Godot was writing the files. The two files that were lost were the script I was editing and the main scene I had also been editing, which probably was also being writen.

I don't know how other apps prevent this, but I wish Godot did. It never happened to me before in any app.

@Zireael07
Copy link
Contributor

I don't know how other apps prevent this, but I wish Godot did. It never happened to me before in any app

Most apps write to a backup file first and then rename

@bojidar-bg
Copy link
Contributor

Hm.. IIRC, Godot does the same, and it's enabled by default:

_initial_set("filesystem/on_save/safe_save_on_backup_then_rename", true);

@Skaruts Can you confirm that Safe Save is enabled in the editor settings for you?

@Skaruts
Copy link
Author

Skaruts commented Dec 19, 2023

@bojidar-bg it's enabled, yes.

@bojidar-bg
Copy link
Contributor

bojidar-bg commented Dec 19, 2023

Hmm - well, that doesn't rule out any bugs in the Windows safe save implementation (though on cursory look it seemed fine)... and even then, there could be bugs in how the disk/disk driver/filesystem handle the rename, since if the rename ends up stored permanently before the data itself is stored, the whole save safe dance doesn't end up mattering.

Would be curious if we could get a reproduction on another disk, or better yet, a reliable reproduction in e.g. a VM. Otherwise, other than some kind of precautionary fsync around

if (!save_path.is_empty()) {
// This workaround of trying multiple times is added to deal with paranoid Windows
// antiviruses that love reading just written files even if they are not executable, thus
// locking the file and preventing renaming from happening.
bool rename_error = true;
, I'm not sure if there's much that can be done.

(tho, fair note, I haven't contributed to Godot recently, and other contributors would probably have more-informed opinions than me here (:' )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants