vector.lua:59: attempt to index local 'b' (a nil value) #1028

Closed
opened 2021-11-10 01:02:18 +00:00 by AliasAlreadyTaken · 7 comments

2021-11-10 02:00:35: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'water_life' in callback luaentity_Step(): ...ve1/5.4.1/Minetest_live/bin/../builtin/common/vector.lua:59: attempt to index local 'b' (a nil value)
2021-11-10 02:00:35: ERROR[Main]: stack traceback:
2021-11-10 02:00:35: ERROR[Main]: ...ve1/5.4.1/Minetest_live/bin/../builtin/common/vector.lua:59: in function 'dist2tgt'
2021-11-10 02:00:35: ERROR[Main]: /home/mtlive1/.minetest/mods/water_life/behaviors.lua:1226: in function 'func'
2021-11-10 02:00:35: ERROR[Main]: /home/mtlive1/.minetest/mods/mobkit/init.lua:621: in function 'execute_queues'
2021-11-10 02:00:35: ERROR[Main]: /home/mtlive1/.minetest/mods/mobkit/init.lua:848: in function 'func'
2021-11-10 02:00:35: ERROR[Main]: ...inetest_live/bin/../builtin/profiler/instrumentation.lua:106: in function <...inetest_live/bin/../builtin/profiler/instrumentation.lua:100>

2021-11-10 02:00:35: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'water_life' in callback luaentity_Step(): ...ve1/5.4.1/Minetest_live/bin/../builtin/common/vector.lua:59: attempt to index local 'b' (a nil value) 2021-11-10 02:00:35: ERROR[Main]: stack traceback: 2021-11-10 02:00:35: ERROR[Main]: ...ve1/5.4.1/Minetest_live/bin/../builtin/common/vector.lua:59: in function 'dist2tgt' 2021-11-10 02:00:35: ERROR[Main]: /home/mtlive1/.minetest/mods/water_life/behaviors.lua:1226: in function 'func' 2021-11-10 02:00:35: ERROR[Main]: /home/mtlive1/.minetest/mods/mobkit/init.lua:621: in function 'execute_queues' 2021-11-10 02:00:35: ERROR[Main]: /home/mtlive1/.minetest/mods/mobkit/init.lua:848: in function 'func' 2021-11-10 02:00:35: ERROR[Main]: ...inetest_live/bin/../builtin/profiler/instrumentation.lua:106: in function <...inetest_live/bin/../builtin/profiler/instrumentation.lua:100>
AliasAlreadyTaken added the
1. kind/bug
2. prio/critical
labels 2021-11-10 01:02:57 +00:00
Owner

Wait a moment.
These stem from water_life, too:

#972
#896
#396

Wait a moment. These stem from water_life, too: #972 #896 #396
AliasAlreadyTaken was assigned by Styxcolor 2021-11-10 08:11:50 +00:00
Author
Owner

2021-11-14 03:59:49: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'water_life' in callback luaentity_Step(): ...ve1/5.4.1/Minetest_live/bin/../builtin/common/vector.lua:59: attempt to index local 'b' (a nil value)
2021-11-14 03:59:49: ERROR[Main]: stack traceback:
2021-11-14 03:59:49: ERROR[Main]: ...ve1/5.4.1/Minetest_live/bin/../builtin/common/vector.lua:59: in function 'dist2tgt'
2021-11-14 03:59:49: ERROR[Main]: /home/mtlive1/.minetest/mods/water_life/behaviors.lua:1226: in function 'func'
2021-11-14 03:59:49: ERROR[Main]: /home/mtlive1/.minetest/mods/mobkit/init.lua:621: in function 'execute_queues'
2021-11-14 03:59:49: ERROR[Main]: /home/mtlive1/.minetest/mods/mobkit/init.lua:848: in function 'func'
2021-11-14 03:59:49: ERROR[Main]: ...inetest_live/bin/../builtin/profiler/instrumentation.lua:106: in function <...inetest_live/bin/../builtin/profiler/instrumentation.lua:100>
2021-11-14 04:01:06: WARNING[Main]: system-wide share not found at "/usr/local/share/minetest"

2021-11-14 03:59:49: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'water_life' in callback luaentity_Step(): ...ve1/5.4.1/Minetest_live/bin/../builtin/common/vector.lua:59: attempt to index local 'b' (a nil value) 2021-11-14 03:59:49: ERROR[Main]: stack traceback: 2021-11-14 03:59:49: ERROR[Main]: ...ve1/5.4.1/Minetest_live/bin/../builtin/common/vector.lua:59: in function 'dist2tgt' 2021-11-14 03:59:49: ERROR[Main]: /home/mtlive1/.minetest/mods/water_life/behaviors.lua:1226: in function 'func' 2021-11-14 03:59:49: ERROR[Main]: /home/mtlive1/.minetest/mods/mobkit/init.lua:621: in function 'execute_queues' 2021-11-14 03:59:49: ERROR[Main]: /home/mtlive1/.minetest/mods/mobkit/init.lua:848: in function 'func' 2021-11-14 03:59:49: ERROR[Main]: ...inetest_live/bin/../builtin/profiler/instrumentation.lua:106: in function <...inetest_live/bin/../builtin/profiler/instrumentation.lua:100> 2021-11-14 04:01:06: WARNING[Main]: system-wide share not found at "/usr/local/share/minetest"
Owner

The server crashes must end. Let's start and hopefully finish operation "snake lobotomy" this week. Even if the waterlife snake mob gets dumber as a result, that is better than returning a nil in some abstract attack vector thing and crashing the server.

The server crashes must end. Let's start and hopefully finish operation "snake lobotomy" this week. Even if the waterlife snake mob gets dumber as a result, that is better than returning a nil in some abstract attack vector thing and crashing the server.
Owner

this is the function in question
function water_life.hq_snake_warn(self,target,prty,duration,anim)
anim = anim or 'warn'
local init = true

local func=function(self)
	if init then 
		mobkit.make_sound(self,"warn")
		minetest.after(1,function(anim)
			mobkit.animate(self,anim)
		end,anim)
		init=false
	end
	local yaw = water_life.get_yaw_to_object(self,target)
	self.object:set_yaw(yaw)
	duration = duration-self.dtime
    
	local dist = water_life.dist2tgt(self,target) --this line brings our server down
	
    if  dist > self.view_range then
		minetest.after(3,function()
			return true
		end)
	end
	if duration <= 0 or dist < 4 then
		mobkit.remember(self,"warned",target:get_player_name())
		return true
	end
end
mobkit.queue_high(self,func,prty)

end

this is the function in question function water_life.hq_snake_warn(self,target,prty,duration,anim) anim = anim or 'warn' local init = true local func=function(self) if init then mobkit.make_sound(self,"warn") minetest.after(1,function(anim) mobkit.animate(self,anim) end,anim) init=false end local yaw = water_life.get_yaw_to_object(self,target) self.object:set_yaw(yaw) duration = duration-self.dtime local dist = water_life.dist2tgt(self,target) --this line brings our server down if dist > self.view_range then minetest.after(3,function() return true end) end if duration <= 0 or dist < 4 then mobkit.remember(self,"warned",target:get_player_name()) return true end end mobkit.queue_high(self,func,prty) end
Owner

unfortunately this goes way beyond my current horizon, as I first have to look into what the mobkit is and how it works.

unfortunately this goes way beyond my current horizon, as I first have to look into what the mobkit is and how it works.
Author
Owner

Good news, we have a repro.

5.5.0-dev or 5.4.1, water_life 211111 and latest mobkit from content db, one MT instance a server, one a client

  1. Replace water_life.dist2tgt with the following in api.lua line ~210
-- distance from self to target
function water_life.dist2tgt(self,tgt)
	core.log("action","self="..dump(self))
	core.log("action","tgt="..dump(tgt))
	local pos = mobkit.get_stand_pos(self)
	local tpos = tgt:get_pos()
	local thp = tgt:get_hp()
	core.log("action","pos="..dump(pos))
	core.log("action","tpos="..dump(tpos))
	core.log("action","thp="..dump(thp))
	return vector.distance(pos,tpos)
end
  1. Enable water_life and mobkit on one instance of MT, lets call it MT1
  2. Start the server on MT1
  3. Start a client on the other instance, lets call it MT2
  4. grant all, get some snakes and release them on MT2
  5. Walk up to the snake on MT2 and match the hq_snake_warn conditions: dist > 4 and dist < self.view_range and not action
  6. As soon as it warns, log out with MT2.

BOOM!

=>

2021-11-18 03:05:21: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'water_life' in callback luaentity_Step(): ...5.5.0-dev/minetest-test/bin/../builtin/common/vector.lua:116: attempt to index local 'b' (a nil value)
2021-11-18 03:05:21: ERROR[Main]: stack traceback:
2021-11-18 03:05:21: ERROR[Main]: 	...5.5.0-dev/minetest-test/bin/../builtin/common/vector.lua:116: in function 'dist2tgt'
2021-11-18 03:05:21: ERROR[Main]: 	...0-dev/minetest-test/bin/../mods/water_life/behaviors.lua:1225: in function 'func'
2021-11-18 03:05:21: ERROR[Main]: 	...test/5.5.0-dev/minetest-test/bin/../mods/mobkit/init.lua:621: in function 'execute_queues'
2021-11-18 03:05:21: ERROR[Main]: 	...test/5.5.0-dev/minetest-test/bin/../mods/mobkit/init.lua:848: in function <...test/5.5.0-dev/minetest-test/bin/../mods/mobkit/init.lua:825>

But why? We obviously have a playerobject. Only that its get_pos() returns nil when logging out??

That's what the debug says:

2021-11-18 03:18:57: ACTION[Server]: pos={
	y = 18.510999679789,
	x = -316.15753173828,
	z = -411.00021362305
}
2021-11-18 03:18:57: ACTION[Server]: tpos=nil
2021-11-18 03:18:57: ACTION[Server]: thp=1

Try it yourself, you may take a couple of attempts to log out the right moment, but its a 100% repro over here by now. No lag or other mods involved but mtg, mobkit and water_life :)

Good news, we have a repro. > 5.5.0-dev or 5.4.1, water_life 211111 and latest mobkit from content db, one MT instance a server, one a client 1. Replace water_life.dist2tgt with the following in api.lua line ~210 ``` -- distance from self to target function water_life.dist2tgt(self,tgt) core.log("action","self="..dump(self)) core.log("action","tgt="..dump(tgt)) local pos = mobkit.get_stand_pos(self) local tpos = tgt:get_pos() local thp = tgt:get_hp() core.log("action","pos="..dump(pos)) core.log("action","tpos="..dump(tpos)) core.log("action","thp="..dump(thp)) return vector.distance(pos,tpos) end ``` 2. Enable water_life and mobkit on one instance of MT, lets call it MT1 3. Start the server on MT1 4. Start a client on the other instance, lets call it MT2 5. grant all, get some snakes and release them on MT2 6. Walk up to the snake on MT2 and match the hq_snake_warn conditions: dist > 4 and dist < self.view_range and not action 7. As soon as it warns, log out with MT2. BOOM! => ``` 2021-11-18 03:05:21: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'water_life' in callback luaentity_Step(): ...5.5.0-dev/minetest-test/bin/../builtin/common/vector.lua:116: attempt to index local 'b' (a nil value) 2021-11-18 03:05:21: ERROR[Main]: stack traceback: 2021-11-18 03:05:21: ERROR[Main]: ...5.5.0-dev/minetest-test/bin/../builtin/common/vector.lua:116: in function 'dist2tgt' 2021-11-18 03:05:21: ERROR[Main]: ...0-dev/minetest-test/bin/../mods/water_life/behaviors.lua:1225: in function 'func' 2021-11-18 03:05:21: ERROR[Main]: ...test/5.5.0-dev/minetest-test/bin/../mods/mobkit/init.lua:621: in function 'execute_queues' 2021-11-18 03:05:21: ERROR[Main]: ...test/5.5.0-dev/minetest-test/bin/../mods/mobkit/init.lua:848: in function <...test/5.5.0-dev/minetest-test/bin/../mods/mobkit/init.lua:825> ``` But why? We obviously have a playerobject. Only that its get_pos() returns nil when logging out?? That's what the debug says: ``` 2021-11-18 03:18:57: ACTION[Server]: pos={ y = 18.510999679789, x = -316.15753173828, z = -411.00021362305 } 2021-11-18 03:18:57: ACTION[Server]: tpos=nil 2021-11-18 03:18:57: ACTION[Server]: thp=1 ``` Try it yourself, you may take a couple of attempts to log out the right moment, but its a 100% repro over here by now. No lag or other mods involved but mtg, mobkit and water_life :)
AliasAlreadyTaken added this to the 1.1.100 milestone 2021-11-18 02:44:41 +00:00
Author
Owner

Fixed in 1e28fc84d386217c17ca10dd330c8fc2c0269bb0

Fixed in 1e28fc84d386217c17ca10dd330c8fc2c0269bb0
AliasAlreadyTaken added the
5. result/fixed
label 2021-11-18 02:51:58 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: your-land/bugtracker#1028
No description provided.