-
Notifications
You must be signed in to change notification settings - Fork 8.2k
libc: newlib: libc-hooks: Provide our own implementation of __chk_fail() #26135
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
|
This is related to #25479. More discussion is available in zephyrproject-rtos/sdk-ng#221 |
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.
Need to add some kind of infinite loop at the end to make sure that this function does not return as per FUNC_NORETURN.
error: 'noreturn' function does return [-Werror]
EDIT: CODE_UNREACHABLE should do.
|
I wonder if there is a per-thread exit that a thread is allowed to call on itself with Zephyr. That would satisfy the noreturn requirement and might also allow for memory to be reused. Ahh... too bad:
https://docs.zephyrproject.org/latest/reference/kernel/threads/index.html#thread-aborting |
This warning/error here is just a compiler construct, because p.s. If |
|
@stephanosio - agreed. #ifndef CONFIG_USERSPACE
k_thread_abort(k_current_get());
#endif? |
|
@cfriedt While you can do that, that should not be necessary: Lines 26 to 39 in 94b9640
|
So, that's where the problem lies, and what needs to be fixed. |
Unfortunately, that would be easier said than done due to how it is implemented. |
Ah, ok, it's proverbial Zephyr with its demigod designers (71ce8ce): Because you see, on some architectures, after a thread is aborted, it makes sense to continue executing its code after the abort. Makes it all more secure. And probably a lot of TOC, TOU, SGX, CBA, FGH, XYZ, and other TLAs involved. |
The version as shipped in Newlib itself is coded a bit sloppily for an embedded environment. We thus want to override it (and make it weak, to allow user apps to override it in turn, if needed). The desired properties of the implementation are: 1. It should call _write() (Newlib implementation calls write()). 2. It should be minimal (Newlib implementation allocates message on the stack, i.e. misses "static const"). Signed-off-by: Paul Sokolovsky <[email protected]>
Added. |
The version as shipped in Newlib itself is coded a bit sloppily for an
embedded environment. We thus want to override it (and make it weak, to
allow user apps to override it in turn, if needed). The desired
properties of the implementation are:
on the stack, i.e. misses "static const").
Signed-off-by: Paul Sokolovsky [email protected]