Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

core: Treat stack overflows as an unrecoverable error #18448

Merged
merged 1 commit into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/lib/include/panic.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ typedef enum {
PANIC_DUMMY_HANDLER, /**< unhandled interrupt */
#endif
PANIC_SSP, /**< stack smashing protector failure */
PANIC_STACK_OVERFLOW, /**< stack overflow detected */
PANIC_UNDEFINED
} core_panic_t;

Expand Down
4 changes: 3 additions & 1 deletion core/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "log.h"
#include "sched.h"
#include "thread.h"
#include "panic.h"

#ifdef MODULE_MPU_STACK_GUARD
#include "mpu.h"
Expand Down Expand Up @@ -130,9 +131,10 @@ static void _unschedule(thread_t *active_thread)
*/
if (*((uintptr_t *)(uintptr_t)active_thread->stack_start) !=
(uintptr_t)active_thread->stack_start) {
LOG_WARNING(
LOG_ERROR(
"scheduler(): stack overflow detected, pid=%" PRIkernel_pid "\n",
active_thread->pid);
core_panic(PANIC_STACK_OVERFLOW, "STACK OVERFLOW");
}
#endif
#ifdef MODULE_SCHED_CB
Expand Down