fix(foundation): prevent Backoff::Linear integer overflow and restore dead DegradationLadder test#1580
Open
vivekrajsingh04 wants to merge 1 commit intomofa-org:mainfrom
Conversation
… dead DegradationLadder test Two related reliability fixes in mofa-foundation: 1. Backoff::Linear::delay_for() used bare + and * operators that panic on integer overflow in debug builds and silently wrap in release builds. Fixed by using saturating_add/saturating_mul and adding a max_ms cap, matching the overflow-safe pattern already used by Backoff::Exponential. Added linear_with_max() constructor for explicit cap control. 2. test_degradation_ladder_degrades_to_q4_when_q8_too_large in routing.rs was missing its #[test] attribute, making it dead code. The critical Q4 degradation path (last safety net before cloud fallback on constrained devices) had zero test coverage. Added the missing attribute. New tests: - test_backoff_linear_saturates_and_caps: verifies no panic on u32::MAX - test_backoff_linear_with_custom_max: verifies explicit cap behavior Fixes #XXXX
Contributor
|
Hey @yangrudan @lijingrs, this PR fixes an integer overflow in Backoff::Linear and restores a dead test. Important safety fix. Could you review when available? 🔍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1579. Details in the issue and commits.