diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2018-12-10 20:13:36 -0800 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2018-12-10 20:13:36 -0800 |
| commit | 8a981dc8e86e077823b8b3ea2240306d8a736cac (patch) | |
| tree | 850096086dc5b9ac5010469c0a3175c0ff223966 /supervisor/shared/stack.c | |
| parent | 09316b35d7b838d735d76639cca462c088d3d18d (diff) | |
| parent | c3c600dfa3ddf6343e7b51a58669a3c3d3c5b58a (diff) | |
Merge remote-tracking branch 'adafruit/master' into sfe840
Diffstat (limited to 'supervisor/shared/stack.c')
| -rwxr-xr-x | supervisor/shared/stack.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/supervisor/shared/stack.c b/supervisor/shared/stack.c index 6b74742eb..71e239c0a 100755 --- a/supervisor/shared/stack.c +++ b/supervisor/shared/stack.c @@ -27,7 +27,9 @@ #include "stack.h" #include "py/mpconfig.h" +#include "py/runtime.h" #include "supervisor/cpu.h" +#include "supervisor/shared/safe_mode.h" extern uint32_t _estack; @@ -50,6 +52,17 @@ void allocate_stack(void) { } else { current_stack_size = next_stack_size; } + *stack_alloc->ptr = STACK_CANARY_VALUE; +} + +inline bool stack_ok(void) { + return *stack_alloc->ptr == STACK_CANARY_VALUE; +} + +inline void assert_heap_ok(void) { + if (!stack_ok()) { + reset_into_safe_mode(HEAP_OVERWRITTEN); + } } void stack_init(void) { @@ -58,6 +71,7 @@ void stack_init(void) { void stack_resize(void) { if (next_stack_size == current_stack_size) { + *stack_alloc->ptr = STACK_CANARY_VALUE; return; } free_memory(stack_alloc); |
