-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
When the delay parameter of k_delayed_work_submit is K_FOREVER, the system will crash #24409
Comments
@andyross we are likely missing a test for this particular usage of delayed work? |
This actually never worked correctly (well, "correctly" -- it's a pathological case after all), and AFAICT the behavior didn't change with the timeout patch. What actually happens in practice is that the delayed work timeout gets set for -1 (== K_FOREVER) ticks into the future, which means it fires immediately at the next timer interrupt. I can't reproduce a crash, btw; it just fires normally but unexpectedly. Maybe your app is hitting an unexpected situation and crashing? As far as a fix: we can either document this as a "don't do that", or (what I think I'll submit) add a check to z_add_timeout() which noops if a K_FOREVER reaches down that far. |
The "forever" token has always been interpreted above z_add_timeout() (because it's always taken ticks, but K_FOREVER used to be in ms). But it was discovered that k_delayed_work_submit_to_queue() was never testing for this and passing a raw K_FOREVER down, where it got interpreted as a negative timeout and caused it to fire at the next tick. Now that we actually see the original k_timeout_t here, we might as well check it locally and do the correct thing (that is, nothing) if asked to schedule a timeout that will never fire. Fixes zephyrproject-rtos#24409 Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
The "forever" token has always been interpreted above z_add_timeout() (because it's always taken ticks, but K_FOREVER used to be in ms). But it was discovered that k_delayed_work_submit_to_queue() was never testing for this and passing a raw K_FOREVER down, where it got interpreted as a negative timeout and caused it to fire at the next tick. Now that we actually see the original k_timeout_t here, we might as well check it locally and do the correct thing (that is, nothing) if asked to schedule a timeout that will never fire. Fixes #24409 Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
The "forever" token has always been interpreted above z_add_timeout() (because it's always taken ticks, but K_FOREVER used to be in ms). But it was discovered that k_delayed_work_submit_to_queue() was never testing for this and passing a raw K_FOREVER down, where it got interpreted as a negative timeout and caused it to fire at the next tick. Now that we actually see the original k_timeout_t here, we might as well check it locally and do the correct thing (that is, nothing) if asked to schedule a timeout that will never fire. Fixes zephyrproject-rtos#24409 Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
The "forever" token has always been interpreted above z_add_timeout() (because it's always taken ticks, but K_FOREVER used to be in ms). But it was discovered that k_delayed_work_submit_to_queue() was never testing for this and passing a raw K_FOREVER down, where it got interpreted as a negative timeout and caused it to fire at the next tick. Now that we actually see the original k_timeout_t here, we might as well check it locally and do the correct thing (that is, nothing) if asked to schedule a timeout that will never fire. Fixes zephyrproject-rtos#24409 Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Describe the bug
If the k_delayed_work_submit function is called with the K_FOREVER parameter, the system will error
To Reproduce
Expected behavior
Calling k_delayed_work_submit with K_FOREVER can directly return an error, or directly return..
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: