-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Fix for 32 bit processors. #1977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The time-outs do not ever time-out on 32 bit processors if t0 happens to be close to 65535. This means that if you try to open an SD card that isn't present your app will sometimes freeze entirely in card.init() rather than returning an error like it is supposed to.
Can I build this pull request? |
Yes? Explain yourself, robot. On 22 August 2014 12:51, ArduinoBot [email protected] wrote:
|
@Timmmm sorry for the comment from arduinobot. we are setting up automated build of all PRs, so that we can provide a downloadable version of the patched IDE |
@Timmmm can u provide me an example sketch that shows the freezing please? |
Just looked at the commit, it looks good to me. AFAIU, what happens is that the compiler applies integer promotion, which on a 32-bit system promotes to uint32_t, breaking the overflow. In the original code:
Both sides of the subtraction are uint16_t, but are promoted to uint32_t before subtracting. Overflow in the subtraction now also happens in 32-bit, breaking the calculation. As an example, consider that Note that my analysis would only explain that the timeout would happen too soon around the overflow time, I can't explain the code locking up (but that might be a side effect of some other code?) I actually think the cast to uint16_t for the result of |
Can one of the admins verify this patch? |
Very interesting bug! |
this is a rework of @Timmmm 's PR arduino#1977
Merged as #2808 |
The time-outs do not ever time-out on 32 bit processors if t0 happens to be close to 65535. This means that if you try to open an SD card that isn't present your app will sometimes freeze entirely in card.init() rather than returning an error like it is supposed to.