MISC/mcl_selftests: Do not crash if minetest.find_nodes_in_area() lies #214
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
3 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Mineclonia/Mineclonia#214
Loading…
Reference in New Issue
No description provided.
Delete Branch "fix-selftest-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: #183
I foolishly added an assertion to the code that crashed the game if the Minetest engine used to run Mineclonia had a
minetest.find_nodes_in_area()
implementation that would not count nodes correctly near the map border.After sfan5 changed
minetest.find_nodes_in_area()
to lie about nodes with coordinate components larger than 31000 or smaller than -31000, this test crashed Mineclonia at startup with dvelopment versions of Minetest. This made several people – among them @cora and sfan5 – upset.@cora convined me that it is wrong to have no error message. @EliasFleckenstein03 convinced me that it is wrong to use
assert()
for non-catastrophic bugs outside of one's own code. Therefore, I have replaced the assertion with a (hopefully helpful) debug message that is printed when the test fails.Solution
Instead of a crash, the game now complains about the bug in the engine via
minetest.debug()
at startup.Details
I removed the
assert()
and inserted anif
statement.Testing Steps
87ab97da2a
with Mineclonia commit6f811b3cee
.87ab97da2a
with Mineclonia commit 7c9845ac3fece869da9725deb04a24434a5955de.minetest.find_nodes_in_area() failed to find 218 nodes that were placed. Downgrading to Minetest 5.4.1 might fix this.
WIP: MISC/mcl_selftests: Do not crash if minetest.find_nodes_in_area() liesto MISC/mcl_selftests: Do not crash if minetest.find_nodes_in_area() liesMineclonia/fix-selftest-crash
and started my Minetest 5.4.1 installation.Mineclonia/master
and started Minetest, compiled from source on the latest commitMineclonia/fix-selftest-crash
and started Minetest, compiled from source on the latest commit2021-12-15 14:00:41: [Server]: minetest.find_nodes_in_area() failed to find 218 nodes that were placed. Downgrading to Minetest 5.4.1 might fix this.
Everything works as expected.
I'm not sure I like this to be honest. I would still prefer these tests only to be run when people explicitly demand them.
It should also be pointed out that the problem here isn't me or anyone else being upset. But the damn game crashing for no actual reason and with no indication of what is wrong.
This way nothing would prevent this from happening again.
Me no longer writing tests containing assertions regarding anything outside of Mineclonia and you not approving them (you told me you would no longer approve of self tests that crash on engine bugs) seems to me like it would prevent this from happening again.
That is a separate issue though. Making the test case not crash does not take away the possibility of disabling tests.
6d88a3378c
to0b5fa14041
1. Start Minetest 5.4.1 with Mineclonia commit 7c9845ac3fece869da9725deb04a24434a5955de.
2. Verify that no debug message is printed at startup.
3. Start Minetest commit
87ab97da2a
with Mineclonia commit6f811b3cee
.4. Verify that the game crashes with a failed assertion in mcl_selftests.
5. Start Minetest commit
87ab97da2a
with Mineclonia commit 7c9845ac3fece869da9725deb04a24434a5955de.6. Verify that a debug message is printed at startup, similar to the folllowing:
minetest.find_nodes_in_area() failed to find 218 nodes that were placed. Downgrading to Minetest 5.4.1 might fix this.