summaryrefslogtreecommitdiffstatshomepage
path: root/lib/utils/pyexec.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-10-13 16:21:08 +1100
committerDamien George <damien.p.george@gmail.com>2018-10-13 16:21:08 +1100
commitf5d46a88aaea61f6c0248c0ac2c5583e7011d634 (patch)
treede0483fdafc1eca427b1fa5de42891c20835ac8d /lib/utils/pyexec.c
parent7059b4af6d651a819daf8b6ea838ae82f62287f0 (diff)
downloadmicropython-f5d46a88aaea61f6c0248c0ac2c5583e7011d634.tar.gz
micropython-f5d46a88aaea61f6c0248c0ac2c5583e7011d634.zip
lib/utils/pyexec: Forcefully unlock the heap if locked and REPL active.
Otherwise there is really nothing that can be done, it can't be unlocked by the user because there is no way to allocate memory to execute the unlock. See issue #4205 and #4209.
Diffstat (limited to 'lib/utils/pyexec.c')
-rw-r--r--lib/utils/pyexec.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/utils/pyexec.c b/lib/utils/pyexec.c
index 5d72419d1a..d8dc60bfe5 100644
--- a/lib/utils/pyexec.c
+++ b/lib/utils/pyexec.c
@@ -419,6 +419,12 @@ friendly_repl_reset:
}
#endif
+ // If the GC is locked at this point there is no way out except a reset,
+ // so force the GC to be unlocked to help the user debug what went wrong.
+ if (MP_STATE_MEM(gc_lock_depth) != 0) {
+ MP_STATE_MEM(gc_lock_depth) = 0;
+ }
+
vstr_reset(&line);
int ret = readline(&line, ">>> ");
mp_parse_input_kind_t parse_input_kind = MP_PARSE_SINGLE_INPUT;