-
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
core/assert: halt running thread instead of panic #20627
Conversation
core/lib/include/assert.h
Outdated
* If the assertion failed in an interrupt, the system will still panic. | ||
*/ | ||
#ifndef DEBUG_ASSERT_ZOMBIFY | ||
#define DEBUG_ASSERT_ZOMBIFY (1) |
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.
#define DEBUG_ASSERT_ZOMBIFY (1) | |
# define DEBUG_ASSERT_ZOMBIFY (0) |
Maybe not change the default to avoid the API change discussion here to get this feature in quickly, and change the default in a follow up PR and let the discussion unfold there?
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.
We have a pattern of including useful features that are just not used because people don't know they exist, or don't turn them on manually all the time (eg. MOST_RECENT_PORT=1), I'd rather not make this one of them.
If there is any pushback on the API change and this makes it faster, fine. If not, let's not hurry to comply with non-requirements.
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.
OK, then let's quickly merge this before there is a large discussion 👿
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.
Thanks, LGTM.
Tested using this change
diff --git a/examples/gcoap/server.c b/examples/gcoap/server.c
index bf2315cd01..e10885a6b6 100644
--- a/examples/gcoap/server.c
+++ b/examples/gcoap/server.c
@@ -151,2 +151,4 @@ static ssize_t _riot_board_handler(coap_pkt_t *pdu, uint8_t *buf, size_t len, co
+ assert(0);
+
/* write the RIOT board name in the response buffer */
and by CoAP requesting .well-known/core (works), /riot/board (causes the panic), and while CoAP is down, the shell still works.
I've pushed a check for a missing include (irq.h, failed to build on native), please confirm and squash.
Looks like some |
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.
core/lib/include/assert.h
core/lib/assert.c
#include "panic.h" | ||
#if IS_USED(MODULE_BACKTRACE) | ||
#include "backtrace.h" | ||
#endif | ||
|
||
__NORETURN void _assert_failure(const char *file, unsigned line) |
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.
Architecture.h
{ | ||
printf("%s:%u => ", file, line); |
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.
CPU.h
__NORETURN void _assert_panic(void) | ||
{ | ||
printf("%" PRIxTXTPTR "\n", cpu_get_caller_pc()); | ||
#if IS_USED(MODULE_BACKTRACE) |
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.
Debug.h
__NORETURN void _assert_panic(void) | ||
{ | ||
printf("%" PRIxTXTPTR "\n", cpu_get_caller_pc()); | ||
#if IS_USED(MODULE_BACKTRACE) | ||
backtrace_print(); |
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.
Irq.h
__NORETURN void _assert_panic(void) | ||
{ | ||
printf("%" PRIxTXTPTR "\n", cpu_get_caller_pc()); | ||
#if IS_USED(MODULE_BACKTRACE) | ||
backtrace_print(); | ||
#endif |
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.
Panic.h
#if IS_USED(MODULE_BACKTRACE) | ||
backtrace_print(); | ||
#endif | ||
#ifdef DEBUG_ASSERT_BREAKPOINT |
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.
Module backtrace
backtrace_print(); | ||
#endif | ||
#ifdef DEBUG_ASSERT_BREAKPOINT | ||
DEBUG_BREAKPOINT(1); |
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.
Backtrace.h
#endif | ||
#ifdef DEBUG_ASSERT_BREAKPOINT | ||
DEBUG_BREAKPOINT(1); | ||
#endif |
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.
No return
#ifdef DEBUG_ASSERT_BREAKPOINT | ||
DEBUG_BREAKPOINT(1); | ||
#endif | ||
core_panic(PANIC_ASSERT_FAIL, "FAILED ASSERTION."); |
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.
Irq.h
@Tanyajackson638 Could you please explain with a few words what you want to say regarding every single comment above? I think in most cases it coule be something like "missing include of ...", but in some of the cases this does not make sense. Just to be sure: You are a human and not a bot, right? |
Weird that |
@Tanyajackson638 Just to be sure: We were unable to understand your review. (To be honest it left me so puzzled I wouldn't be surprised if your review would be the result of a bot/script behaving unexpectedly.) If you do have any concerns or questions regarding this PR, please voice them here and we will try our best to address them. |
Contribution description
Instead of taking down the whole system, just kill the running thread.
Testing procedure
Add an
assert(0)
somewhere.Issues/PRs references
fixes #20626