-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
k_wakeup follwed by k_thread_resume call causes system freeze #28694
Comments
We don't generally do defensive state checking in kernel APIs. Indeed, resuming an unsuspended thread or waking up a non-sleeping one is a fatal error, and exactly the behavior you get is essentially undefined. It's no different than trying to do things like double-remove a list item, etc... I suppose someone could add some assertions in there to check state. |
I confirm that https://github.com/pabigot/rhardik-reproduce-zephyr-issues/commits/issue/28694 has three commits, the first updating the example to current Zephyr APIs, and the second making the test a little nicer to work with, and the third refining the distinction between the behaviors. Below is the summary of the functional changes and observed behavior. Shorten the delay and print a running timestamp in the dummy thread. Simplify compile-time selection of whether the dummy thread Use a counter to iterate through four responses to SW1 press:
If the dummy thread does not self-suspend then k_wakeup alone, and k_thread_resume alone, both work. When both are invoked, the program hangs. This appears to be a bug. If the dummy thread does self-suspend then
|
These are syscalls so even if we are lax about checking correct usage from supervisor mode contexts, a nefarious user thread shouldn't be able to cause corruption or DoS via the syscalls, at minimum needs to be 100% robust from user threads (and very likely worth making robust from all contexts). I'd say Medium priority is appropriate. |
that is not true per the documentation:
and
Both calls should just have no effect, it should not hang or crash. |
Do not try to resume a thread that was not suspended. Fixes zephyrproject-rtos#28694 Signed-off-by: Anas Nashif <[email protected]>
Do not try to resume a thread that was not suspended. Fixes #28694 Signed-off-by: Anas Nashif <[email protected]>
Do not try to resume a thread that was not suspended. Fixes zephyrproject-rtos#28694 Signed-off-by: Anas Nashif <[email protected]>
Describe the bug
I've added a while loop with 8 seconds sleep in a thread. Now by mistake I called both k_wakeup and k_thread_resume which is causing system to get freeze without any crash logs.
To Reproduce
Steps to reproduce the behaviour:
2.$ cd reproduce-zephyr-issues
while (1) { k_sleep(K_MSEC(8000)); printk("flag = %d\n",dummy_flg); printk("%s\n", __func__); //k_thread_suspend(dummy_tid); }
10. Recompile and flash the code.
11. Press button-0 to see if suspend thread works or not.
12. Press button-1 to resume the thread.
13. See at UART terminal: while loop continuously running without considering k_sleep(8000)
Expected behavior
System should not get freeze if I call k_thread_resume after k_wakeup (Note: thread in sleep state here)
Impact
annoyance.
Logs and console output
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: