Splizard / minetest-mod-snow

Adds snow biomes to Minetest.
http://splizard.com/minetest/mods/snow-biomes/
Other
10 stars 9 forks source link

attempt to call a nil value #25

Closed 00c closed 7 years ago

00c commented 7 years ago

Snow mod cause minetest to crash on startup

2016-11-21 11:04:22: ERROR[Main]: ModError: Failed to load and run script from /home/minetest/bin/../mods/snow/init.lua:
2016-11-21 11:04:22: ERROR[Main]: /home/minetest/bin/../mods/snow/src/util.lua:108: attempt to call a nil value
2016-11-21 11:04:22: ERROR[Main]: stack traceback:
2016-11-21 11:04:22: ERROR[Main]:   /home/minetest/bin/../mods/snow/src/util.lua:108: in main chunk
2016-11-21 11:04:22: ERROR[Main]:   [C]: in function 'dofile'
2016-11-21 11:04:22: ERROR[Main]:   /home/minetest/bin/../mods/snow/init.lua:64: in main chunk
HybridDog commented 7 years ago

https://www.lua.org/manual/5.1/manual.html#pdf-io.lines

00c commented 7 years ago

This happens with recent minetest_game, works fine with older version

volkj commented 7 years ago

It may be related to recent minetest changes https://github.com/minetest/minetest/commit/3af5eef96463510a27cf06b9c3ecc9f1d04cdac6

Tested the mod, crashes with mod security on but works normally disabling it, using minetest-dev e403115 so not fixed on my side

SmallJoker commented 7 years ago

This here should work just fine:

util.lua L106
-   io.close(file)
+
    config = {}
-   for line in io.lines(path) do
+   for line in file:lines() do
        if line:sub(1,1) ~= "#" then
            local i, v = line:match("^(%S*) = (%S*)")
            if i and v then
                config[i] = value_from_string(v)
            end
        end
    end
+   io.close(file)
end
HybridDog commented 7 years ago

Thanks, l applied your changes.

00c, please tell me if the crash still happens.

00c commented 7 years ago

Thanks, no more crashes. For now works fine with recent minetest_game and minetest server.