diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2018-10-22 17:57:28 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2018-12-04 23:26:04 -0800 |
| commit | 7ad2e6ace34a6d417ec1b84472fa409d5451137b (patch) | |
| tree | 57e75e8a4759607f2efce0e032c13d81b2c38e0e /py | |
| parent | 4b5edd3c03623aa09043d337e69efa4e384cf0a4 (diff) | |
Add stack validity check and raise an error when it happens.
The backtrace cannot be given because it relies on the validity
of the qstr data structures on the heap which may have been
corrupted.
In fact, it still can crash hard when the bytecode itself is
overwritten. To fix, we'd need a way to skip gathering the
backtrace completely.
This also increases the default stack size on M4s so it can
accomodate the stack needed by ASF4s nvm API.
Diffstat (limited to 'py')
| -rw-r--r-- | py/obj.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -33,10 +33,12 @@ #include "py/objtype.h" #include "py/objint.h" #include "py/objstr.h" +#include "py/qstr.h" #include "py/runtime.h" #include "py/stackctrl.h" #include "py/stream.h" // for mp_obj_print +#include "supervisor/shared/stack.h" #include "supervisor/shared/translate.h" mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) { @@ -81,7 +83,7 @@ void mp_obj_print(mp_obj_t o_in, mp_print_kind_t kind) { // helper function to print an exception with traceback void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) { - if (mp_obj_is_exception_instance(exc)) { + if (mp_obj_is_exception_instance(exc) && stack_ok()) { size_t n, *values; mp_obj_exception_get_traceback(exc, &n, &values); if (n > 0) { |
