mobkit/init.lua:46: attempt to index local 'pos' (a nil value) #8335

Open
opened 2025-03-29 16:42:01 +01:00 by AliasAlreadyTaken · 9 comments
2025-03-29 11:52:44: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'water_life' in callback environment_Step(): /home/yl/5.10.0/Yourland_test/bin/../mods/mobkit/init.lua:46: attempt to index local 'pos' (a nil value)
2025-03-29 11:52:44: ERROR[Main]: stack traceback:
2025-03-29 11:52:44: ERROR[Main]: 	/home/yl/5.10.0/Yourland_test/bin/../mods/mobkit/init.lua:46: in function 'pos_shift'
2025-03-29 11:52:44: ERROR[Main]: 	...yl/5.10.0/Yourland_test/bin/../mods/water_life/spawn.lua:335: in function 'spawnstep'
2025-03-29 11:52:44: ERROR[Main]: 	...yl/5.10.0/Yourland_test/bin/../mods/water_life/spawn.lua:454: in function 'func'
2025-03-29 11:52:44: ERROR[Main]: 	...ourland_test/bin/../builtin/profiler/instrumentation.lua:124: in function <...ourland_test/bin/../builtin/profiler/instrumentation.lua:117>
2025-03-29 11:52:44: ERROR[Main]: 	.../5.10.0/Yourland_test/bin/../builtin/common/register.lua:26: in function <.../5.10.0/Yourland_test/bin/../builtin/common/register.lua:12>
``` 2025-03-29 11:52:44: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'water_life' in callback environment_Step(): /home/yl/5.10.0/Yourland_test/bin/../mods/mobkit/init.lua:46: attempt to index local 'pos' (a nil value) 2025-03-29 11:52:44: ERROR[Main]: stack traceback: 2025-03-29 11:52:44: ERROR[Main]: /home/yl/5.10.0/Yourland_test/bin/../mods/mobkit/init.lua:46: in function 'pos_shift' 2025-03-29 11:52:44: ERROR[Main]: ...yl/5.10.0/Yourland_test/bin/../mods/water_life/spawn.lua:335: in function 'spawnstep' 2025-03-29 11:52:44: ERROR[Main]: ...yl/5.10.0/Yourland_test/bin/../mods/water_life/spawn.lua:454: in function 'func' 2025-03-29 11:52:44: ERROR[Main]: ...ourland_test/bin/../builtin/profiler/instrumentation.lua:124: in function <...ourland_test/bin/../builtin/profiler/instrumentation.lua:117> 2025-03-29 11:52:44: ERROR[Main]: .../5.10.0/Yourland_test/bin/../builtin/common/register.lua:26: in function <.../5.10.0/Yourland_test/bin/../builtin/common/register.lua:12> ```
AliasAlreadyTaken added the
1. kind/bug
3. source/testserver
labels 2025-03-29 16:44:30 +01:00
Author
Owner

This is due to This is due to water_life

water_life.noSpawn = minetest.settings:get_bool("water_life_nospawn ") or false

There's a surplus blank at the end of the setting key: water_life_nospawn

This is on main, means we'll get the crash there sooner or later as well.

This is due to This is due [to water_life](https://gitea.your-land.de/your-land/water_life/src/branch/master/init.lua#L63) ``` water_life.noSpawn = minetest.settings:get_bool("water_life_nospawn ") or false ``` There's a surplus blank at the end of the setting key: water_life_nospawn This is on main, means we'll get the crash there sooner or later as well.
Author
Owner

Since this is actually two separate issues, here are both upstream issues:

https://github.com/berengma/water_life/issues/108
https://github.com/berengma/water_life/issues/107

Since this is actually two separate issues, here are both upstream issues: https://github.com/berengma/water_life/issues/108 https://github.com/berengma/water_life/issues/107
Member

Main won't crash because:
c58e503cf3/spawn.lua (L84-L88)

Because Alias has set temporary water_life.apionly = true :D

Main won't crash because: https://gitea.your-land.de/your-land/water_life/src/commit/c58e503cf32f0787af26b49cf887d3a4bb9ac3f3/spawn.lua#L84-L88 Because Alias has set temporary `water_life.apionly = true` :D
Member

Both issues closed upstream with new commits.

Both issues closed upstream with new commits.
whosit added the
4. step/ready to QA test
label 2025-04-09 19:29:23 +02:00
AliasAlreadyTaken added this to the 1.1.128 milestone 2025-04-09 23:29:44 +02:00
Member

This crashed us so many times, we should've hotfixed it in some way.
I'm thinking about just finding the globalstep by the mod origin and replacing it with the fixed one with nil check added.

I still don't understand how exactly this can happen though?

This crashed us so many times, we should've hotfixed it in some way. I'm thinking about just finding the globalstep by the mod origin and replacing it with the fixed one with nil check added. I still don't understand how exactly this can happen though?
Member

I still don't understand how exactly this can happen though?

coraltable[random(#coraltable)] is where it goes wrong:
random is a custom func which looks quite cursed: c58e503cf3/api.lua (L31-L43)

random(1) can return 0. But lua indices start at 1...

> I still don't understand how exactly this can happen though? `coraltable[random(#coraltable)]` is where it goes wrong: `random` is a custom func which looks quite cursed: https://gitea.your-land.de/your-land/water_life/src/commit/c58e503cf32f0787af26b49cf887d3a4bb9ac3f3/api.lua#L31-L43 `random(1)` can return 0. But lua indices start at 1...
Member

(not correcting tour, because he's right, trying to unconfuse mylself)

random(1) can return 0. But lua indices start at 1...

Maybe this is where this horrible monster comes from? Trying to make sure "min = 1"? XD

lua's math.random(1) will return only 1 (!)
But, after all the shuffling, water_life.random(1) is equivalent to water_life.random(0, 1) and to math.random(0,1) which will return 0 or 1 :)

(not correcting tour, because he's right, trying to unconfuse mylself) > random(1) can return 0. But lua indices start at 1... Maybe this is where this horrible monster comes from? Trying to make sure "min = 1"? XD lua's `math.random(1)` will return only `1` (!) But, after all the shuffling, `water_life.random(1)` is equivalent to `water_life.random(0, 1)` and to `math.random(0,1)` which _will_ return 0 or 1 :)
AliasAlreadyTaken added the
4. step/QA main
label 2025-05-08 00:14:52 +02:00
Member

This fix is not on main, we got a crash :p (judging by the line numbers too)
did water_life.apionly = true again...

/eval water_life.version

upstream: 250329
we have: 250122

This fix is not on main, we got a crash :p (judging by the line numbers too) did `water_life.apionly = true` again... `/eval water_life.version` upstream: 250329 we have: 250122
Member

water_life.apionly = true is now a snippet temp_fix_water_life_8335
please disable when updated :p

`water_life.apionly = true` is now a snippet `temp_fix_water_life_8335` please disable when updated :p
AliasAlreadyTaken modified the milestone from 1.1.128 to Next 2025-05-26 00:18:34 +02:00
AliasAlreadyTaken added
4. step/at work
and removed
4. step/ready to QA test
4. step/QA main
labels 2025-05-26 00:19:09 +02:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 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#8335
No description provided.