ENTITIES/mcl_item_entity: Fix non-serializable item entity unload crash #132
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#132
Loading…
Reference in New Issue
No description provided.
Delete Branch "fix-overlong-meta-item-crash-2"
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: #129
Some items, like shulkers or books, can have so much metadata that the
corresponding item entity can not be serialized by the Minetest engine.
Without this patch, dropping such an item and then moving away crashes
Minetest, as it can not serialize the entity with serializeString16()
when unloading a map block.
Solution
The patch resets the overlong metadata of non-serializable item entities.
This avoids a crash and makes it possible to retrieve a “sanitized” item
without metadata when the mapblock containing the item entity is reloaded.
Details
The modified get_staticdata() function was given to me by sfan5 on IRC.
I also got the permission to use the code “under any license you want”:
https://irc.minetest.net/minetest/2021-07-28#i_5853853
The original threshold for serialization size given by sfan5 was wrong.
@anon5 calculated the correct size here: #131 (comment)
Testing Steps
Preparation
ce6d6c26cc
.Verify Bug
45cdad7283
.45cdad7283
.Verify Patch
ce6d6c26cc
.To do
WIP: ENTITIES/mcl_item_entity: Fix non-serializable item entity unload crashto ENTITIES/mcl_item_entity: Fix non-serializable item entity unload crash@anon5 does this PR look correct?
@Li0n mentioned that it should be tested if a book or shulker gets its inventory deleted immediately or only on unload. I modified the testing instructions accordingly.
Preparation
ce6d6c26cc
.[...]
[...]
Verify Bug
45cdad7283
.45cdad7283
.Verify Patch