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

Write-to-read problem with configs, leading to weird side effects #9122

Closed
IchHabeHunger54 opened this issue Oct 31, 2022 · 11 comments
Closed
Assignees
Labels
1.19 Assigned This request has been assigned to a core developer. Will not go stale. Bug This request reports or fixes a new or existing bug. Confirmed This request has been verified to be factually correct by at least one member of the team.

Comments

@IchHabeHunger54
Copy link

Minecraft Version: 1.19.2

Forge Version: 43.1.47

Logs: N/A

Steps to Reproduce:
This is a bit of a problem. I have not found a reliable way to reproduce. See the details below.

Description of issue:
There is a write-on-read problem with Forge's config system. When the config is read, the contents read are written to the same file. This can lead to side effects such as config backups being created and the config being reset to normal for no reason at all. As mentioned, this is not reliably reproducable. I can't really pinpoint a reason why, either, but some discussion on Discord suggested that ForgeConfigSpec#correct is broken in one way or another.

@IchHabeHunger54 IchHabeHunger54 added the Triage This request requires the active attention of the Triage Team. Requires labelling or reviews. label Oct 31, 2022
@AterAnimAvis AterAnimAvis added Bug This request reports or fixes a new or existing bug. 1.19 Triage This request requires the active attention of the Triage Team. Requires labelling or reviews. and removed Triage This request requires the active attention of the Triage Team. Requires labelling or reviews. labels Oct 31, 2022
@TheCurle
Copy link
Contributor

This is what also causes the corruption issue with Notepad++, and the occasional blanking out to 14 nul values of configs.

I've spent weeks worth of time scouring all the config related functions, i'm certain that the issue lies within NightConfig at this point.

Assigning this to myself for posterity.

@TheCurle TheCurle added Confirmed This request has been verified to be factually correct by at least one member of the team. Assigned This request has been assigned to a core developer. Will not go stale. and removed Triage This request requires the active attention of the Triage Team. Requires labelling or reviews. labels Oct 31, 2022
@TheCurle TheCurle self-assigned this Oct 31, 2022
embeddedt added a commit to embeddedt/ModernFix that referenced this issue Jul 18, 2023
Block file watcher from proceeding until config is done saving

Related: MinecraftForge/MinecraftForge#9122
@TheElectronWill
Copy link

TheElectronWill commented Aug 31, 2023

Hi! NightConfig's author here.
I've analysed the problem reported in neoforged/NeoForge#32, probably caused by multiple concurrent events conflicting with each other, and maybe dependent on the editor used to edit the file. I don't know why it hasn't been reported sooner in my repository, but now that I'm aware of it, I'll be able to publish a solution :)

@TheElectronWill
Copy link

TheElectronWill commented Jan 28, 2024

Update: TheElectronWill/night-config#152 has been merged with a full rewrite of FileConfig, based on concurrent configurations (see the comments on the PR). When the new API is used properly, it should hopefully fix the problem.

@PaintNinja
Copy link
Contributor

That's great, although we're waiting for that to be published in a new release first so that we're able to update and start taking advantage of your fixes.

@TheElectronWill
Copy link

I've just released NightConfig v3.7.0 with the aforementioned fixes and more (sorry for the wait)

@SrRapero720
Copy link
Contributor

@TheElectronWill have you done any breaking change on the 3.6.7 -> 3.7.0 transition?
At least to attempt PR a backport

@TheElectronWill
Copy link

According to japicmp, there is no breaking change. Replacing NightConfig 3.6.x by NightConfig 3.7.x should "just work" (at the very least, it will compile).

Use 3.7.1 instead of 3.7.0, it fixes a misconfiguration of the Gradle build (TheElectronWill/night-config#173). It should be available in a few hours.

@LexManos
Copy link
Member

LexManos commented May 13, 2024

Binary wise it doesn't look like there are any breaking changes, source wise there is one that effects Forge.
The removal of the throws on addWatch makes the compiler complain about unreachable code. Which is simple enough to update for.

I looked over all your changes last night and it seems fine. Did some testing and with a little tweaking was about to us the bulk operations on my correct function but haven't pushed the changes until I can talk to @PaintNinja because I saw his PR about making the builder simpler and wanted to talk to him about it.

As for backports, it should just be the version bump and couple lines change to not have a try and call it good.

@LexManos
Copy link
Member

Found another breaking change in 3.7.1, namely tomls don't work at all as they don't use StampedConfig as their internal implementation.
But seems you've fixed that in 3.7.3. But there is another breaking change I ran into. StampedConfig doesn't support valueMap().
Got a work around, but honestly, these issues mean I can't backport the changes as modders could easily be relying on those behaviors and a backport would mean breaking those mods.

@TheElectronWill
Copy link

But seems you've fixed that in 3.7.3. But there is another breaking change I ran into. StampedConfig doesn't support valueMap().

Does Forge actually use it? A search on GitHub and Gitlab seemed to show that it's very rarely used, let alone with StampedConfig/async FileConfigs. In any case, valueMap() on the pre-3.7.0 FileConfig is broken because it cannot provide any form of synchronization, which is one of the causes of config corruption.

@LexManos
Copy link
Member

It did in a few places. Which i have had to remove while updating to address a reported issue of 7.3.1 being non functional.

8edb551

Jonathing pushed a commit to Jonathing/MinecraftForge that referenced this issue Jun 19, 2024
Jonathing pushed a commit to Jonathing/MinecraftForge that referenced this issue Jun 19, 2024
Jonathing pushed a commit to Jonathing/MinecraftForge that referenced this issue Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.19 Assigned This request has been assigned to a core developer. Will not go stale. Bug This request reports or fixes a new or existing bug. Confirmed This request has been verified to be factually correct by at least one member of the team.
Projects
None yet
Development

No branches or pull requests

7 participants