mesecons
mesecons copied to clipboard
Memory leaks when using Luacontroller memory
Minetest forum user Hectic disclosed to me that executing programs on Luacontrollers that use mem
such as this one
if (event.type == "program") then
mem.var = 0
end
interrupt(1,"stepper")
if (event.type == "interrupt" and event.iid == "stepper") then
mem.var = mem.var + 1
print(mem.var)
end
will lead to high memory usage of the minetest server and can apprently lead to a memory overflow / serious lag on the server. This might potentially be a bug in minetest or any other underlying framework, so I don't know if I can fix this in mesecons; we should investigate this nevertheless.
I highly encourage users that find potentially serious bugs that could affect servers to responsibly disclose issues to me personally and want to thank Hectic for that. In this case, however, I could not manage to reproduce the bug on any of my machines, so this is why I am looking for people to report test results on their computers. Please build several (like 20) luacontrollers and run them with the code above in your game (for 30 minutes - 1 hour). Please run client and server separately so that you can accuratly report on the memory usage of the server. We are looking for the following information:
- Are you experiencing increased memory usage of the server after some time (without players on the server, so only memory leaks from the luacontrollers)?
- What operating system / version are you on?
- Are you using Lua or LuaJIT (press escape ingame, and look for
USE_LUAJIT
on the left)? - Which minetest and mesecons versions are you using?
- Are there any other factors that you think might cause this memory overflow?
From Hectic's and my tests, this is what we have found out so far:
- We couldn't reproduce the bug on Linux yet
- The bug occurs on Windows 7
- I wasn't able to reproduce the bug on Windows 10
Thanks in advance to all testers!
I am not sure if this may be related - i experience serious memory leak problems on my server. I cannot really prove it yet but this time it was way worse than usual and around this time, a player launched a bigger than usual machine, powering a technic constructor and five nodebreakers+deployers using a microcontroller.
They used this code:
interrupt(1, "clock")
if (event.iid == "clock") then
port.c = false
port.b = false
if (mem.check == true) then
mem.check = false
port.c = true
else
mem.check = true
port.b = true
end
end
The swap usage grew crazily fast after hitting the configured memory limit... .
@verymilan Can you show a screenshot of the construction? The luacontroller code seems rather simple and shouldn't cause problems.
Here you go :)
@verymilan I guess the problem might be many items cycling around in the tubes which would be pipeworks fault. Try to avoid such loops with pipworks tubes. (Crossing tubes and priority tubes might be helpful.) The mesecons part of the constructions shouldn't cause any problems. (It might of course be possible that I overlook something very weird.)
Pipeworks has a limiter; if too many items start flowing, tubes start breaking.