diff options
Diffstat (limited to 'ports/unix')
-rw-r--r-- | ports/unix/input.c | 3 | ||||
-rw-r--r-- | ports/unix/main.c | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/ports/unix/input.c b/ports/unix/input.c index 31926a5a8..260e9eac8 100644 --- a/ports/unix/input.c +++ b/ports/unix/input.c @@ -104,6 +104,9 @@ void prompt_write_history(void) { #if MICROPY_USE_READLINE == 1 char *home = getenv("HOME"); if (home != NULL) { + if (MP_STATE_THREAD(gc_lock_depth) != 0) { + return; + } vstr_t vstr; vstr_init(&vstr, 50); vstr_printf(&vstr, "%s/.micropython.history", home); diff --git a/ports/unix/main.c b/ports/unix/main.c index 51d99ce5f..0acd8c9f2 100644 --- a/ports/unix/main.c +++ b/ports/unix/main.c @@ -209,6 +209,9 @@ static int do_repl(void) { mp_hal_stdio_mode_raw(); input_restart: + // 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. + MP_STATE_THREAD(gc_lock_depth) = 0; vstr_reset(&line); int ret = readline(&line, mp_repl_get_ps1()); mp_parse_input_kind_t parse_input_kind = MP_PARSE_SINGLE_INPUT; |