GZDoom eats and overrides config files

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.

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: GZDoom eats and overrides config files

Re: GZDoom eats and overrides config files

by Rachael » Wed Aug 11, 2021 4:56 am

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

Re: GZDoom eats and overrides config files

by Major Cooke » Tue Aug 10, 2021 8:35 pm

At long last. I'll give it a try soon and make a new post if I encounter any issues.

Re: GZDoom eats and overrides config files

by Graf Zahl » Tue Aug 10, 2021 2:10 pm

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.

Re: GZDoom eats and overrides config files

by drfrag » Tue Mar 09, 2021 6:11 am

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.

Re: GZDoom eats and overrides config files

by drfrag » Fri Mar 05, 2021 2:01 pm

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;
}

Re: GZDoom eats and overrides config files

by Rachael » Thu Mar 04, 2021 8:02 am

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.

Re: GZDoom eats and overrides config files

by drfrag » Thu Mar 04, 2021 6:41 am

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.

Re: GZDoom eats and overrides config files

by Apeirogon » Wed Mar 03, 2021 5:54 pm

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 2481 times
2051 year version
new — копия — копия.png
new — копия — копия.png (6.63 KiB) Viewed 2481 times

Re: GZDoom eats and overrides config files

by Major Cooke » Wed Mar 03, 2021 2:56 pm

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.

Re: GZDoom eats and overrides config files

by drfrag » Wed Mar 03, 2021 1:49 pm

Precisely, i added a check for file existence but you assume that the file doesn't exist becouse it can't be read. It's a bad habit usually seen in old code.
Are you sure that it cannot happen without pressing the restart button? That said that should be fixed too if it actually happens.

Re: GZDoom eats and overrides config files

by _mental_ » Wed Mar 03, 2021 9:49 am

drfrag wrote:Interesting but that doesn't change the fact that the original source was wrong and FileExists is broken on windows. When pressing restart with my changes you should still get the config error and be able to investigate the problem.
Your proposal won't change anything. The config file does exist, but it cannot be opened for reading because it's already opened for writing.

Re: GZDoom eats and overrides config files

by Major Cooke » Wed Mar 03, 2021 9:45 am

It's pretty rare when it happens. If anything I'd suggest loading up intensive mods that take a lot of memory for example such as AEons of Death. Maybe it having to unload more may trigger it to occur more often? Just a guess, but perhaps that may cause more overlap.

Re: GZDoom eats and overrides config files

by drfrag » Wed Mar 03, 2021 4:11 am

Okay i can't reproduce it with a bad zscript.txt, even restarting many times.

Re: GZDoom eats and overrides config files

by Graf Zahl » Tue Mar 02, 2021 3:53 pm

No, that's to be expected. Sometimes the two processes do not overlap their access, sometimes they do. A classic case of unsynchronized access to a non-shareable resource.

Re: GZDoom eats and overrides config files

by Major Cooke » Tue Mar 02, 2021 2:44 pm

It doesn't happen all the time. Just sometimes. So it's still as enigmatic as any other.

Top