You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Minetest 5.9.0-dev-b4be483d3 (Linux)
Using Irrlicht 1.9.0mt14
Using LuaJIT 2.1.0-beta3
Built by GCC 12.2
Running on Linux/6.1.0-18-amd64 x86_64
BUILD_TYPE=Debug
RUN_IN_PLACE=0
USE_CURL=1
USE_GETTEXT=1
USE_SOUND=1
STATIC_SHAREDIR="/usr/local/share/minetest"
STATIC_LOCALEDIR="/usr/local/share/locale"
Irrlicht device
X11
Operating system and version
Debian 12 bookworm
CPU model
AMD Ryzen 5 7600
GPU model
No response
Active renderer
No response
Summary
On trying to reprogram an ATC Controller node in Advtrains today I received the following error:
AsyncErr: Lua: Runtime error from mod '' in callback node_on_receive_fields(): /home/blockhead/.minetest/mods/advtrains/advtrains/atc.lua:146: bad argument #2 to 'set_string' (string expected, got nil)
stack traceback:
[C]: in function 'set_string'
/home/blockhead/.minetest/mods/advtrains/advtrains/atc.lua:146: in function </home/blockhead/.minetest/mods/advtrains/advtrains/atc.lua:123>
Previously the mod had always worked fine when updating ATC controllers. However, there are definitely some old vestiges in the controller code that were causing the problem:
There is a lot of commented-out code related to an old idea of digilines connections to the tracks. There is also the obsolete field channel, which is not on the present formspec, but is used anyway to set the value of a metadata field on the node. So all requests to set it are actually just asking to set it to nil. That may just have been an error on the part of Advtrains, but it worked until now.
By git bisecting I found the pull request that introduced the problem: #14368. The set_string method was changed to construct a string_view with readParam:
@@ -115,9 +115,7 @@ int MetaDataRef::l_set_string(lua_State *L)
MetaDataRef *ref = checkAnyMetadata(L, 1);
std::string name = luaL_checkstring(L, 2);
- size_t len = 0;- const char *s = lua_tolstring(L, 3, &len);- std::string str(s, len);+ auto str = readParam<std::string_view>(L, 3);
which doesn't allow a nil string, and this check pushes an error onto the Lua stack and causes the first crash.
Solutions
Make an exception to the nil checking applied in other parts of the code to allow the set_string function to continue to allow nil values and preserve backwards-compatibility.
Document that the value argument must not be nil.
Steps to reproduce
Install Advtrains and enable all the modules in a world.
Place an ATC Controller node.
Open the ATC Controller node's formspec with right-click.
Click the Save button on the formspec.
The text was updated successfully, but these errors were encountered:
Minetest version
Irrlicht device
X11
Operating system and version
Debian 12 bookworm
CPU model
AMD Ryzen 5 7600
GPU model
No response
Active renderer
No response
Summary
On trying to reprogram an ATC Controller node in Advtrains today I received the following error:
Previously the mod had always worked fine when updating ATC controllers. However, there are definitely some old vestiges in the controller code that were causing the problem:
There is a lot of commented-out code related to an old idea of digilines connections to the tracks. There is also the obsolete field
channel
, which is not on the present formspec, but is used anyway to set the value of a metadata field on the node. So all requests to set it are actually just asking to set it to nil. That may just have been an error on the part of Advtrains, but it worked until now.By
git bisect
ing I found the pull request that introduced the problem: #14368. The set_string method was changed to construct a string_view with readParam:which uses this template:
which doesn't allow a nil string, and this check pushes an error onto the Lua stack and causes the first crash.
Solutions
set_string
function to continue to allow nil values and preserve backwards-compatibility.Steps to reproduce
The text was updated successfully, but these errors were encountered: