minar::ticks() crashes after 50 days.
- Dominant language
- C++
- Stars
- 26
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
Behold this code, in `minar.cpp`:
```
/// convert ticks into the milliseconds time representation
uint32_t minar::ticks(minar::platform::tick_t ticks){
uint64_t milliseconds = ((uint64_t)ticks * 1000U) / minar::platform::Time_Base;
assert(milliseconds <= 0xFFFFFFFF);
return (uint32_t)milliseconds;
}
```
2^32 milliseconds is only 50 days. That is not enough. The easiest fix is to have it return `uint64_t` instead, which gives. 500k years (that is enough). mBed is actually full of timer wrapping issues. It really needs a thorough review.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in minar.cpp at minar::ticks(), then inspect its callers before changing the return type. Check how scheduler timing values are consumed and verify behavior beyond 2^32 milliseconds; done means the conversion no longer asserts or truncates at the 50-day limit and the affected code still builds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100