-
Notifications
You must be signed in to change notification settings - Fork 2k
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
sys: xtimer: fix some race conditions #4903
Conversation
@immesys Could you give this a try? |
@kaspar030 sure. I will run it overnight and let you know. |
There's one thing this PR doesn't fix: the same race as @immesys, for spinning timers. I didn't know what would be the best semantic:
I tend to go with 4.), as it is easy to implement and probably leads most to expected behaviour. |
Thanks @immesys! |
@immesys @kaspar030 what's the status here? Needs rebase btw |
About to do some more testing of this, but @kaspar030 it needs some rebasing. |
|
Sweet! |
ACK for the change in general, waiting for @immesys report from their testing |
I actually hit some timer problems today, but as I was hacking on something else, it might have been an unrelated newly introduced user error. Can you give me tomorrow to test it specifically? Ideally I might also be able to contribute a test case. |
@immesys All the time you need! ;) |
Any progress? |
Huh, I commented on this, maybe it was on the issue not the PR. I think this looks good and should be merged. If I track down why I was still getting a lockup in _remove then I will open a new issue but it is very rare and might be the debugger interfering with things. |
👍 then go. |
sys: xtimer: fix some race conditions
(sorry just saw that this passed and was ACKed. Did not track the issues to that) |
This PR (hopefully) fixes two issues:
#4902:
previously, _xtimer_set_absolute() would determine the current _long_cnt outside of a critical section, then determine using _this_high_period() whether the timer shoots in current or next period. If the overflow interrupt occurs in between, long_target is too low (and thus not in _this_high_period()), causing the timer to wrongly be added to the long list. This PR moves the critical section over initial _long_cnt determination.
#4841:
Previously, xtimer_set() would remove a timer outside of a critical section, then call _xtimer_set_absolute(). If the same timer would be set in between, it could end up twice in a timer list, causing xtimer to hang.
This PR refactors xtimer_remove into a safe and unsafe variant and adds a second check using the unsafe variant in _xtimer_set_absolute()'s critical section.