Dwarf Fortress Bug Tracker - Dwarf Fortress
View Issue Details
0001777Dwarf FortressTechnical -- Generalpublic2010-05-05 22:172017-05-17 14:21
The Architect 
 
highblockhave not tried
newopen 
Vista
0.31.03 
 
0001777: Multiple instances of DF can run simultaneously in same folder, resulting in save corruption
Saving simultaneously in duplicate DF applications causes corruption in one or more.

"One of the compressed files on disk has errors on it. Restore from backup if you are able."
Back up your data/save folder.
Open DF twice from the same copy, open two separate forts. Save both simultaneously. If the program manages to complete both saves, attempt to open the files.
No tags attached.
has duplicate 0002641resolved Footkerchief Multiple instances of the game can be opened 
has duplicate 0005518resolved Knight Otu Simultaneously using legends mode and adventure mode might lead to save file problems 
Issue History
2010-05-05 22:17The ArchitectNew Issue
2010-05-05 22:25FootkerchiefNote Added: 0006241
2010-05-05 22:27FootkerchiefNote Edited: 0006241bug_revision_view_page.php?bugnote_id=0006241#r2325
2010-06-29 07:38FootkerchiefCategoryTechnical => Technical -- General
2010-07-11 16:50FootkerchiefRelationship addedhas duplicate 0002641
2010-07-11 16:50FootkerchiefSummarySaving simultaneously with two DF programs causes file corruption => Multiple instances of DF can run simultaneously in same folder, resulting in save corruption
2010-07-11 17:17shibdibNote Added: 0009985
2012-03-01 02:14Knight OtuRelationship addedhas duplicate 0005518
2012-03-01 06:04zombiejusticeNote Added: 0020942
2012-03-01 07:08FootkerchiefNote Added: 0020943
2012-03-01 09:00thvazNote Added: 0020947
2012-03-01 09:02XotanoNote Added: 0020948
2012-09-20 08:04FootkerchiefRelationship addedhas duplicate 0006204
2013-06-06 15:11BrilliandNote Added: 0023994
2014-01-20 19:06FootkerchiefRelationship deletedhas duplicate 0006204
2017-05-11 13:16alexchandelNote Added: 0036522
2017-05-17 14:21lethosorNote Added: 0036537

Notes
(0006241)
Footkerchief   
2010-05-05 22:25   
(edited on: 2010-05-05 22:27)
Most likely because they're sharing the "current" folder. That was probably the motivation for this old bug entry:

# 000020 □ [technical] (http://www.bay12forums.com/smf/index.php?topic=21812.0 [^]) stop multiple copies of the program from being open

(0009985)
shibdib   
2010-07-11 17:17   
confirmed still in 0.31.10
(0020942)
zombiejustice   
2012-03-01 06:04   
This doesn't seem like high priority: you're doing something OUTSIDE the game, that you know will break the game. Should this be closed as 'working as intended'?
(0020943)
Footkerchief   
2012-03-01 07:08   
As I mentioned in the first note, this was in the old bug list that Toady used to maintain (dev_bugs.html).
(0020947)
thvaz   
2012-03-01 09:00   
If he never got around to fix it, maybe he doesn't know how? He may need some help then.

I have little experience as a programmer, but this doesn't sound like something that would demand a lot of time.
(0020948)
Xotano   
2012-03-01 09:02   
well you would think people would refrain from opening multiple game windows.
(0023994)
Brilliand   
2013-06-06 15:11   
Multiple instances of DF being able to load the same save is a good thing. However, it should probably balk at overwriting a save that doesn't match the one it loaded (say, store a version number somewhere). If that happens, it could maybe offer to save in a different folder.

That's getting pretty far away from the "permanent death" ideal, but I don't like permanent death anyway. :p
(0036522)
alexchandel   
2017-05-11 13:16   
I recently had to run two DF instances at once, so I'm glad it's possible.

Assuming you don't attempt to save, and kill both processes with killall/SIGTERM, is there any possible way DF can corrupt any of its files?

As far as behavior, the only change that could be added is: locking on a lock-file in the region folder when saving, so that another process doesn't try to simultaneously save and corrupt the files.
(0036537)
lethosor   
2017-05-17 14:21   
If you don't save, as far as I know, the only files that will be touched are those in data/save/current, which is cleared periodically.

However, I would still recommend not doing what you did, because DF could be confused if it tries to read files from data/save/current and gets files from another save, or if it fails to read files that the other DF process deleted already.

As for your locking suggestion, that wouldn't prevent corruption, because if data/save/current contains files from two different saves, they'll still be copied into the wrong region folder(s).