ITEMS/REDSTONE/mcl_comparators: Fix redstone comparator flooding crash #284
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
4 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Mineclonia/Mineclonia#284
Loading…
Reference in New Issue
No description provided.
Delete Branch "fix-comparator-cauldron-water-crash"
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: #283
Redstone comparators have two modes, comparison mode & subtraction mode.
Before this patch, the functions to turn comparators on or off attempted
to swap nodes with comparators in the same mode, but failed to determine
the correct replacement node, if the existing node was not a comparator.
When a comparator in an on state (e.g. powered by a filled cauldron) was
flooded, the flooding dropped the comparator and replaced the comparator
node that was to be swapped out with air, which lead to a server crash.
Solution
This patch changes the functions that turn comparators on or off so they
only swap existing nodes with comparators in the same mode if the name
of the replacement node can be determined – i.e. if it is not nil.
Details
The patch uses
minetest.after()
. This means there exists a race condition:If the server shuts down during the 0.1 seconds where a comparator is turned
on or off, the on/off state of the comparator might be bugged in the future.
Testing Steps
Verify Bug
d9764fdac6
./grantme debug
./spawnstruct test_structure_comparator
while looking west.mcl_buckets:bucket_water
).Verify Patch
Prerequisites
be915478af
./grantme debug
.mcl_buckets:bucket_water
) and empty buckets (mcl_buckets:bucket_empty
).Verify that the crash is fixed
/spawnstruct test_structure_comparator
while looking west.mcl_comparators:comparator_off_comp
).Verify comparator still works in comparison mode
/spawnstruct test_structure_comparator
.mcl_comparators:comparator_on_comp
) and that a short time later the redstone lamp turns on (mesecons_lightstone:lightstone_on
).mcl_comparators:comparator_off_comp
) and that a short time later the redstone lamp turns off (mesecons_lightstone:lightstone_off
)Verify comparator still works in subtraction mode
/spawnstruct test_structure_comparator
.mcl_comparators:comparator_off_sub
).mcl_comparators:comparator_on_sub
) and that a short time later the redstone lamp turns on.This should be tested using a test structure.
73bb0ff3b0
to0b779bb273
0b779bb273
toe4e12c0b80
@kabou I have addded a test structure for comparators that you can spawn using the command
/spawnstruct test_structure_comparator
if you havedebug
priv. Could you please try to spawn it in commit f092af372faee3b624cca4806d9b701d40591b01 and try to induce a crash, then tell me how to do that? I can not seem to do it. Thank you!Could not get a crash with your test structure.
Made a different test structure.
No crash.
checkout commit from 2 weeks ago.
crash.
checkout your latest commit.
no crash.
Just to be clear, did you try to crash it with my test structure on commit f092af372faee3b624cca4806d9b701d40591b01 or on some other commit?
$ git log -1
commit e4e12c0b804eb82784e180210a3316ff9f65ac8f (HEAD -> master)
Author: Nils Dagsson Moskopp nils@dieweltistgarnichtso.net
Date: Mon Feb 21 16:51:52 2022 +0100
@kabou ok but can you crash it using my test structure one commit before the fix?
If yes, please tell me where to put the water, I can not figure it out myself.
Like so:
The inner comparator can also cause a crash like this:
e4e12c0b80
to715a188c8c
WIP: Fix redstone comparator flooding crashto Fix redstone comparator flooding crashFix redstone comparator flooding crashto ITEMS/REDSTONE/mcl_comparators: Fix redstone comparator flooding crash715a188c8c
tobe915478af
It seems that the crash depends on the orientation of the comparator.
I did
/spawnstruct test_structure_comparator
…… and for each structure I filled first the cauldron, then put water on top of the lamp.
It only ever crashed when I was spawning the test structure looking west.
I tested it, it only crashes if you spawn the structure while looking west
All tests worked out, crash is fixed. Tested in 5.4.1 and 5.5 – for some reason the crash still happens in waspsaliva (some 5.4-dev) though. But it's proably not worth investigating.
I had it crash in all directions but it was in ws i suppose which seems to be more sensitive to this anyways lol.