Skip to content
Snippets Groups Projects
Commit e89cc13e authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

nlr: If DEBUG, guard against recursive nlr_push().

Pushing same NLR record twice would lead to "infinite loop" in nlr_jump
(but more realistically, it will crash as soon as NLR record on stack is
overwritten).
parent 53e5e0fa
No related branches found
No related tags found
No related merge requests found
......@@ -88,6 +88,7 @@ void nlr_jump_fail(void *val);
#ifndef DEBUG
#define nlr_raise(val) nlr_jump(val)
#else
#include "mpstate.h"
#define nlr_raise(val) \
do { \
void *_val = val; \
......@@ -95,6 +96,10 @@ void nlr_jump_fail(void *val);
assert(mp_obj_is_exception_instance(_val)); \
nlr_jump(_val); \
} while (0)
#define nlr_push(val) \
assert(MP_STATE_VM(nlr_top) != val),nlr_push(val)
#endif
#endif // __MICROPY_INCLUDED_PY_NLR_H__
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment