PLAYER/wieldview: Fix server crash by client leaving after joining #138
No reviewers
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#138
Loading…
Reference in New Issue
No description provided.
Delete Branch "fix-server-crash-by-client-leaving-after-joining"
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?
Problem
TRACKING ISSUE: #104
When a player joins and immediately leaves the game before a function is
called by
minetest.after()
inmods/PLAYER/wieldview/init.lua
, it gets aninvalidated player object. This results in the player methods returning
nil
(since Minetest 5.2); perhaps surprisingly, the player is notnil
.Not checking that the result of
player:get_pos()
is notnil
could leadto a server crash if a client crashed when joining. It has been reported
that a syntax error in a client side mod was enough to trigger that.
Solution
If the result of
player:get_pos()
equalsnil
, the function returns early.Details
The Minetest modding bookb by rubenwardy describes this as a common mistake:
https://rubenwardy.com/minetest_modding_book/en/quality/common_mistakes.html
Testing Steps
The game only crashes if a player manages to quit the server before a function is executed on join.
Since the crash involves a race condition, source code must be modified to win the race every time.
(“Winning the race” here means being able to quit a server before the crashy function is executed.)
Verify Bug
3cd4ad5591
.mods/PLAYER/wieldview/init.lua
fromminetest.after(0, function(player)
tominetest.after(10, function(player)
mods/PLAYER/wieldview/init.lua
Verify Patch
10ce37d887
.mods/PLAYER/wieldview/init.lua
fromminetest.after(0, function(player)
tominetest.after(10, function(player)
To do
WIP: Fix server crash by client leaving after joiningto WIP: PLAYER/wieldview: Fix server crash by client leaving after joiningWIP: PLAYER/wieldview: Fix server crash by client leaving after joiningto PLAYER/wieldview: Fix server crash by client leaving after joiningVerify Bug
3cd4ad5591
.mods/PLAYER/wieldview/init.lua
fromminetest.after(0, function(player)
tominetest.after(10, function(player)
mods/PLAYER/wieldview/init.lua
Verify Patch
10ce37d887
.mods/PLAYER/wieldview/init.lua
fromminetest.after(0, function(player)
tominetest.after(10, function(player)