Persistent Creative Inventory

Persistent Creative Inventory

59 Downloads

ModList iteration Concurrency

Tamaized opened this issue ยท 2 comments

commented

The foreach loop on getMods here can cause a concurrency crash

for (ModInfo info : ModList.get().getMods()) {

See: https://pastebin.com/kyusjJUg

I propose instead that ModList.get().getAllScanData() is used in place as ctm does here:
https://github.com/Chisel-Team/ConnectedTexturesMod/blob/fb779c2ffe8727505a3f03fc77840dbc5139e0a4/src/main/java/team/chisel/ctm/client/texture/type/TextureTypeRegistry.java#L32

The only main thing that needs to be done either way is a new list creation and iterating over the clone instead of the original list.

commented

Hi, thank you for your report. I wonder is there any codes that is modifying this list?

commented

My mod MelonGolem does as it was required in the past to enable the config gui button however forge has since changed the need to return true on ModInfo#hasConfigUI so I can remove that old cruft code~

However it should be noted that since mod loading is parallel it's safe to assume this list can be volatile and may be modified by another mod for a different reason and will again cause another concurrency issue. Better safe than sorry imo.