-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Kernel runtime error checking #16702
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
|
All checks are passing now. Review history of this comment for details about previous failed status. |
e67ea4e to
334a863
Compare
kernel/queue.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitipick: if the list is empty, the function could just return here?
andrewboie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get rid of some of the checks in sys_mutex code since the base implementation is now doing it.
be503b3 to
492441d
Compare
a037c1e to
0b68b7b
Compare
kernel/pipes.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you make it boolean operations ? e.g z_waitq_head(&pipe->wait_q.readers) != NULL
include/kernel.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why change it if this function always return 0 ? There is nothing to check here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, you are not approving?
I'm not the kernel maintainer, so it is for me to give a +2.
My concerns have been addressed. So this is just a +0.
ioannisg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some minor comments from my side
arch/Kconfig
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe some text in the help-text should be added, to justify the dependency
kernel/mem_slab.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
early return here, instead?
@aescolar this isn't helpful. |
@andrewboie Thanks. I understand I'm allowed to approve the PR. But the thing is that I do not support the overall direction things are going, but I will not oppose it either while the inconvenience for my company or others trying to target constrained platforms are not too great. |
@aescolar @nashif as far I understood, it is possible for this patch to have no overhead, if the introduced Kconfig switches are set properly, i.e. disable both ASSERT and NO_RUNTIME error checking, am I correct? |
What? Be specific |
Disregard for platform constrained targets. |
This has nothing to do with functional safety. The fact that we are not able to test basic APIs because we just crash is bad for EVERYONE. |
@aescolar let's explore this. |
The fact that I removed my -1 would be an indication that it does not anymore. Wouldn't it? |
2a4b2ac to
4db0fdf
Compare
Define there options for runtime error handling: - assert on all errors (ASSERT_ON_ERRORS) - no runtime checks (no asserts, no runtime error handling) (NO_RUNTIME_CHECKS) - full runtime error handling (the default) (RUNTIME_ERROR_CHECKS) Signed-off-by: Anas Nashif <[email protected]>
k_mutex_unlock will now perform error checking and return on failures. If the current thread does not own the mutex, we will now return -EPERM. In the unlikely situation where we own a lock and the lock count is zero, we assert. This is considered an undefined bahviour and should not happen. Signed-off-by: Anas Nashif <[email protected]>
Check for errors at runtime and stop depending on ASSERTs. This changes the API for - k_sem_init k_sem_init now returns -EINVAL on invalid data. Signed-off-by: Anas Nashif <[email protected]>
Remove static helper functions used only once and integrate them into calling functions. In k_sem_take, return at the end. Signed-off-by: Anas Nashif <[email protected]>
Add runtime error checking to k_pipe_cleanup and k_pipe_get and remove asserts. Adapted test which was expecting a fault to handle errors instead. Signed-off-by: Anas Nashif <[email protected]>
When trying to cancel a NULL work queue return -EAGAIN. Signed-off-by: Anas Nashif <[email protected]>
Add runtime error checking for k_mem_slab_init and replace asserts with returning error codes. Signed-off-by: Anas Nashif <[email protected]>
Add runtime error handling for k_msgq_cleanup. We return 0 on success now and -EAGAIN when cleanup is not possible. Signed-off-by: Anas Nashif <[email protected]>
Add runtime error checking for both k_stack_push and k_stack_cleanup. Signed-off-by: Anas Nashif <[email protected]>
Runtime error handling for k_queue_append_list and k_queue_merge_slist. Signed-off-by: Anas Nashif <[email protected]>
Add tests for k_sem_init. Signed-off-by: Anas Nashif <[email protected]>
Introduce runtime error checking in the kernel where it make sense and remove duplication of asserts and oopses that were used to catch such errors. Propagate errors where needed.
Ideally we want to use this to check for parameters and permissions and return to the caller to allow recovery, which was not possible in the current approach: when asserts are enabled (not default) we would just crash on every error, even if recoverable or we will get undefined behavior if asserts were not enabled.
Situations which should never happen and disallowed by design, such as running something in an ISR when it should not, remain as asserts where applicable.
(Edit by @aescolar) Discussed in #17105