Breakdown of possible fixes to avoid future erroneous state and runtime panic #26
Labels
No labels
complexity
high
complexity
low
complexity
medium
importance
high
importance
low
importance
medium
type
bug
type
chore
type
feature suggestion
type
missing feature
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
thetxt/oxide#26
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
The panic mentioned in #8 was caused by an index into an array being out of bounds and could be avoided by checking the value and skipping writing if the index is invalid. Below is a breakdown of a subset of the most common causes of panics to be evaluated on which can be handled gracefully and which are irrecoverable. Handling all of these cases are not likely to be possible as some irrecoverable states are expected in many projects but determining which are and avoiding code like it in the future will help the project avoid a large amount of bugs as it grows more mature.
Cheers! :)
Total instances of call to unwrap() not including unwrap_or() unwrap_or_default() or similar. The bare unwrap() function panics if called on anything other than an Ok() type
Regex used:
unwrap()total: 751Total instances of reading from or writing to an array (attempted to avoid matching type declaration). Writing to or reading from a vector out of range by accident is quite common and will lead to a panic at runtime.
Regex used:
(?<!#!)(?<!#)(?<! )(?<!&)(?<!\[)(?<!vec!)\[Total: 133Total instances of division, the denominator (divisor) must never be zero, division by zero results in a panic at runtime.
Regex used:
( / )|( % )Total: 52Sorry for the long issue. I tried to make it concise but still detailed.
The array mentioned in #8 stores the block state IDs of a single chunk section, so its length will always be 4096. The only case where this is different, is when a chunk section only contains air, then the array is simply empty. I just forgot to check if a section is empty before placing a new block within it.
And yes I am aware that unwrap() will panic. I will gradually add more robust error handling logic as things get more mature (: