GZDoom eats and overrides config files

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: GZDoom eats and overrides config files

Post by Major Cooke »

Again, try a more resource intensive mod. It has to unload more stuff when it restarts. That might make it easier to trigger. Particularly a mod with a lot of content.
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: GZDoom eats and overrides config files

Post by Apeirogon »

Two separate instances of Gzdoom launched with broken code produce, with restart of one of them, same result. But that was to be expected.
Day, month, year
"Today" version
new — копия.png
new — копия.png (6.34 KiB) Viewed 2482 times
2051 year version
new — копия — копия.png
new — копия — копия.png (6.63 KiB) Viewed 2482 times
User avatar
drfrag
Vintage GZDoom Developer
Posts: 3193
Joined: Fri Apr 23, 2004 3:51 am
Location: Spain
Contact:

Re: GZDoom eats and overrides config files

Post by drfrag »

No, for me it doesn't happen with two instances. Same restarting only one with BDv21 and a bad zscript.txt twenty times in a row.
Edit: just happened now only with the bad zscript.txt.
User avatar
Rachael
Posts: 13945
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: GZDoom eats and overrides config files

Post by Rachael »

I know in Windows at least you can easily look up the shares of a file - I am not sure what functions are involved - but if there's any other process that has it open for writing (I think you can check for that too) it can wait for up to 5 seconds for the operation to complete and if it doesn't - then it could error out and tell you it can't read the config file.

But that might not solve the race condition completely.
User avatar
drfrag
Vintage GZDoom Developer
Posts: 3193
Joined: Fri Apr 23, 2004 3:51 am
Location: Spain
Contact:

Re: GZDoom eats and overrides config files

Post by drfrag »

But where? I've done some investigation and i'm lost here.
I can reproduce it consistently pressing restart but i don't know where the problem is. Some food for thought: after pressing restart several times i can see the config has been reset at the iwad selection startup window. You can see that easily selecting another backend different from the default one and saving the config earlier. Then i've noticed that when you press exit in the picker the config is not saved so when i see that the settings have been reset and exit the config file is not overriden. If i restart again of course i lose my config file.
With my code (but it's the same in GZDoom) i can see putting a Printf that the file is opened succesfully and the succ variable is true every time even when the config is reset. If i remove the read permission from the file before restarting i get the "Could not open config file error message". And it's not something related to saving since i exit without saving and i never get the dialog with the "configuration not saved" error.

Code: Select all

void FConfigFile::LoadConfigFile ()
{
	FileReader file;
	bool succ;

	FileExisted = FileExists(PathName.GetChars());

	if (!file.OpenFile (PathName))
	{
		if (!FileExisted)
			return;
		else
			I_Error ("Could not open config file.\n");
	}

	succ = ReadConfig (&file);
	FileExisted = succ;
}
User avatar
drfrag
Vintage GZDoom Developer
Posts: 3193
Joined: Fri Apr 23, 2004 3:51 am
Location: Spain
Contact:

Re: GZDoom eats and overrides config files

Post by drfrag »

It was a corrupt config file and the configuration was reset, i've added a check for that and then you can restart again.
https://github.com/drfrag666/gzdoom/com ... aa748a848d
Edit: i've noticed that my post was a bit confusing. What's happening here is that the file is still being written while being read so a lock would be required like Cacodemon345 said but that's not that simple so i agree his solution is okay. Nonetheless i wanted to add several checks to see if the file is a valid config (actually if you load any random text file you'll silently get a factory default configuration which is fine in most cases), that also helps becouse OkayToWrite is false at that point. So i wanted to know what was going on and now i do, if i remember right some people have reported partially reset configurations.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49230
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: GZDoom eats and overrides config files

Post by Graf Zahl »

Should be fixed for good now. The restart may not be triggered from within the dialog box, it may only be done after all subsystems have been shut down.
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: GZDoom eats and overrides config files

Post by Major Cooke »

At long last. I'll give it a try soon and make a new post if I encounter any issues.
User avatar
Rachael
Posts: 13945
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: GZDoom eats and overrides config files

Post by Rachael »

That's a much better solution than simply adding a timer.
Post Reply

Return to “Closed Bugs [GZDoom]”