Server crash on client crash #104
Labels
No Label
blocker
bug
code quality
confirmed
critical
discussion
high priority
incompatibility
incomplete feature
invalid
low priority
missing feauture
needs testing
packet spam
performance
project
regression
translations
unconfirmed
in review
ready for review
No Milestone
No project
No Assignees
2 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Mineclonia/Mineclonia#104
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What happened?
I was trying to log into clamity and being stupid as i am i had a syntax error in an unfinished csm and boom the server crashed right after my client crashed. I did it multiple times with multiple accounts which are at different locations.
Here's the error message i got from the friendly substitute admin Clamork ^^
What did I expect?
I expected my miserable failure at lua to not affect server operation i.e. I expected the server not to crash even if my client did so horribly.
How to get it to happen
I will try to reproduce it locally today
Environment
Mineclonia Version: commit
00ee2d5013
(current master)Minetest Version:https://github.com/ClamityAnarchy/minetest/
So what appears to be happening is this: wieldview calls minetest.add_entity with the player position as argument. This happens 1 step after on_joinplayer(, which passes the player object via minetest.after. When the client crashes though the player object is already removed and get_pos returns nil. This is the on_joinplayer:
It seems somewhat likely this might not be the only place where this is happening. It's not a huge problem pracitcally speaking as long as noone abuses it but we should still investigate this.
I have not been able to reproduce it locally so far. Not sure what's going on.
This can be reproduced locally by increasing the timeout for
minetest.after()
to a few seconds, and connecting to a server, then disconnecting within that timeframe.I wondered why there is a minetest.after() with a time of 0 (i.e. immediate).
So far the only thing I suspect is that this creates a new execution context.
When a player disappears, then in the body of the anonymous function called by minetest.after() the player variable is still valid, but
player:get_pos()
returnsnil
.This means that the code needs to check if
player:get_pos()
is nil.I tried to figure out if there exist more functions called by minetest.after() that take a player argument:
From the following comment in
mods/ITEMS/mcl_potions/functions.lua
I deduce that the purpose of the minetest.after() can be to force a wait of at least one server tick:The code in
mods/ITEMS/mcl_portals/portal_nether.lua
contains a probably working check for a player that left (checking ifplayer:get_pos()
returns something falsy):This bug looks like an instance of a common mistake, according to rubenwardy:
https://rubenwardy.com/minetest_modding_book/en/quality/common_mistakes.html
Fixed with merge of PR #138 I guess.