You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(fx): saturate TimeWarp steps that do not fit in int32 - #5302
TimeWarp::applyExact() clamps the scaled step to 2147483647.0f before casting it to i32. But 2147483647.0f isn't representable as a float and rounds to 2147483648.0f. Every clamped value is therefore 2^31, making the cast undefined. On x86 the cast returns INT32_MIN. The step then looks negative, so the rollover protection resets the time to 0 instead of moving it forward. This happens when a single update covers more than 2^31 scaled ms, for example 3000000000 ms at speed 1 or 3000000 ms at speed 1000. The negative branch also computes -diff, which overflows when diff is INT32_MIN.
The fix compares against 2^31 directly and saturates the step to INT32_MAX or INT32_MIN. It also computes the absolute value in unsigned arithmetic. Steps inside the int32 range are cast exactly as before.
I added a subcase in tests/fl/fx/time.cpp to cover these cases. I also built time.cpp.hpp on its own with UBSan float-cast-overflow and ran the existing checks along with the new ones. With the old code, UBSan reports both overflows and the two forward cases give 0. The new code passes all the checks with no reports. I didn't run the full FastLED test runner.
Summary by CodeRabbit
Bug Fixes
Large forward and reverse time updates now stay within the supported range, avoiding overflow and producing consistent results at normal and accelerated speeds.
Tests
Added coverage for time updates that exceed the supported range.
applyExact() clamped the scaled step to 2147483647.0f, which is 2^31 as a
float, so the cast to i32 was undefined. On x86 it gives INT32_MIN and the
time was reset to 0 instead of moving forward. Also negate diff without
overflowing when it is INT32_MIN.
CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.
Parsing warnings: 1
Validation error: Unrecognized key: "enabled" at "reviews.pre_merge_checks"
If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
No actionable comments were generated in the recent review.
Walkthrough
TimeWarp::applyExact now saturates scaled time at the i32 limits before conversion and computes negative delta magnitude with unsigned arithmetic. Tests cover large forward updates at normal and 1000× speed, plus a large reverse update.
Changes: TimeWarp integer boundary handling
Layer / File(s)
Summary
Saturation and boundary tests src/fl/fx/time.cpp.hpp, tests/unit/fl/fx/time.cpp
applyExact saturates scaled time before conversion and computes negative delta magnitude with unsigned arithmetic. Tests cover large forward updates at normal and 1000× speed, and a large reverse update.
This change fixes TimeWarp so very large time steps saturate correctly instead of overflowing or wrapping negative. Boundary tests were added. No merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: TimeWarp scaled steps that exceed the int32 range are saturated. The raw summary and PR objectives both describe a saturation fix in TimeWarp::applyExact, with a match…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: TimeWarp scaled steps that exceed the int32 range are saturated. The raw summary and PR objectives both describe a saturation fix in TimeWarp::applyExact, with a matching test addition. The title is specific and related to the changeset, so it passes.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between 6a74988 and 3fea6df.
Files selected for processing: 1
tests/unit/fl/fx/time.cpp
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
github-actionsBot
added
sanitized
Title, body and conversation screened; review text requires separate screening.
and removed
sanitized
Title, body and conversation screened; review text requires separate screening.
labels
Nov 19, 2026
github-actionsBot
added
sanitized
Title, body and conversation screened; review text requires separate screening.
and removed
sanitized
Title, body and conversation screened; review text requires separate screening.
labels
Nov 19, 2026
github-actionsBot
added
sanitized
Title, body and conversation screened; review text requires separate screening.
and removed
sanitized
Title, body and conversation screened; review text requires separate screening.
labels
Nov 24, 2026
github-actionsBot
added
sanitized
Title, body and conversation screened; review text requires separate screening.
and removed
sanitized
Title, body and conversation screened; review text requires separate screening.
labels
Nov 24, 2026
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
sanitizedTitle, body and conversation screened; review text requires separate screening.
2 participants
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.
TimeWarp::applyExact() clamps the scaled step to 2147483647.0f before casting it to i32. But 2147483647.0f isn't representable as a float and rounds to 2147483648.0f. Every clamped value is therefore 2^31, making the cast undefined. On x86 the cast returns INT32_MIN. The step then looks negative, so the rollover protection resets the time to 0 instead of moving it forward. This happens when a single update covers more than 2^31 scaled ms, for example 3000000000 ms at speed 1 or 3000000 ms at speed 1000. The negative branch also computes -diff, which overflows when diff is INT32_MIN.
The fix compares against 2^31 directly and saturates the step to INT32_MAX or INT32_MIN. It also computes the absolute value in unsigned arithmetic. Steps inside the int32 range are cast exactly as before.
I added a subcase in tests/fl/fx/time.cpp to cover these cases. I also built time.cpp.hpp on its own with UBSan float-cast-overflow and ran the existing checks along with the new ones. With the old code, UBSan reports both overflows and the two forward cases give 0. The new code passes all the checks with no reports. I didn't run the full FastLED test runner.
Summary by CodeRabbit