Random Mod System Bug


Maris
  • Closed

Sometimes server crashes.

I have a mod with following code:

mods = {}

local function SearchForModsByName()
	if mods.active_mods_by_name then
		return --Already initialized.
	end
	mods.active_mods_by_name = {}
	if not (_G.KnownModIndex and _G.KnownModIndex.savedata and _G.KnownModIndex.savedata.known_mods) then
		print("ERROR COMMON LIB: Can't find KnownModIndex!")
		return
	end
	for name,mod in pairs(_G.KnownModIndex.savedata.known_mods) do
		if (mod.enabled or mod.temp_enabled or _G.KnownModIndex:IsModForceEnabled(name)) --Mod is active.
			and not mod.temp_disabled --And not disabled.
		then
			local real_name = mod.modinfo.name
			mods.active_mods_by_name[real_name] = true
		end
	end
end

Server crashes on line:

mods.active_mods_by_name[real_name] = true

with message:

[00:15:25]: [string "../mods/workshop-666155465/modmain.lua"]:280: table index is nil

Does it mean that mod.modinfo is real table but mod.modinfo.name is nil? Is it bug of the game or I missed something?

print(mod.modinfo) -- a table
print(mod.modinfo.name) -- nil

I'm just trying to detect some other mods to improve compatibility with my mod.


Steps to Reproduce
I can't tell you the steps because it's random rare issue. I think it depends on how correct mods are downloaded. But it's only my opinion. I have only log.txt http://pastebin.com/XfNwqiBw


User Feedback


....

ModIndex:InitializeModInfo does check if mod's modinfo sets name, then ModIndex:LoadModInfo disables the mod and marks it bad via ModIndex:DisableBecauseBad. But the its KnownModIndex.savedata.known_mods[badmodfoldername].modinfo.name would be still nil.
Maybe the bad mod got temp_enabled of force_enabled?

From the log it's not clear, as it shows only the last crashing part, not what mods are to be loaded, got loaded and their order.

  • Like 1

Share this comment


Link to comment
Share on other sites
.... ....

modinfo.name being nil is possible when there isn't a name defined. We use the function ModIndex:GetModFancyName to do the nil check on this.

That said I don't know why a folder with a single txt file (which is technically enough to be recognized as a mod) is enabled in your use case.
 

Share this comment


Link to comment
Share on other sites
....


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now