Enter safe mode when an allocation is attempted on an uninitialized heap.
This commit is contained in:
parent
ef4a74e201
commit
03be42ab84
|
@ -9,7 +9,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-03-08 12:45-0800\n"
|
||||
"POT-Creation-Date: 2019-03-12 11:17-0700\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -289,6 +289,10 @@ msgstr ""
|
|||
msgid "Array values should be single bytes."
|
||||
msgstr ""
|
||||
|
||||
#: supervisor/shared/safe_mode.c
|
||||
msgid "Attempted heap allocation when MicroPython VM not running.\n"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "Auto-reload is off.\n"
|
||||
msgstr "Auto-reload tidak aktif.\n"
|
||||
|
|
|
@ -9,7 +9,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-03-08 12:45-0800\n"
|
||||
"POT-Creation-Date: 2019-03-12 11:17-0700\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -287,6 +287,10 @@ msgstr ""
|
|||
msgid "Array values should be single bytes."
|
||||
msgstr ""
|
||||
|
||||
#: supervisor/shared/safe_mode.c
|
||||
msgid "Attempted heap allocation when MicroPython VM not running.\n"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "Auto-reload is off.\n"
|
||||
msgstr ""
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-03-08 12:45-0800\n"
|
||||
"POT-Creation-Date: 2019-03-12 11:17-0700\n"
|
||||
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
|
||||
"Last-Translator: Pascal Deneaux\n"
|
||||
"Language-Team: Sebastian Plamauer, Pascal Deneaux\n"
|
||||
|
@ -289,6 +289,10 @@ msgstr "Array muss Halbwörter enthalten (type 'H')"
|
|||
msgid "Array values should be single bytes."
|
||||
msgstr "Array-Werte sollten aus Einzelbytes bestehen."
|
||||
|
||||
#: supervisor/shared/safe_mode.c
|
||||
msgid "Attempted heap allocation when MicroPython VM not running.\n"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "Auto-reload is off.\n"
|
||||
msgstr "Automatisches Neuladen ist deaktiviert.\n"
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-03-08 12:45-0800\n"
|
||||
"POT-Creation-Date: 2019-03-12 11:17-0700\n"
|
||||
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
@ -287,6 +287,10 @@ msgstr ""
|
|||
msgid "Array values should be single bytes."
|
||||
msgstr ""
|
||||
|
||||
#: supervisor/shared/safe_mode.c
|
||||
msgid "Attempted heap allocation when MicroPython VM not running.\n"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "Auto-reload is off.\n"
|
||||
msgstr ""
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-03-08 12:45-0800\n"
|
||||
"POT-Creation-Date: 2019-03-12 11:17-0700\n"
|
||||
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: @sommersoft, @MrCertainly\n"
|
||||
|
@ -289,6 +289,10 @@ msgstr ""
|
|||
msgid "Array values should be single bytes."
|
||||
msgstr ""
|
||||
|
||||
#: supervisor/shared/safe_mode.c
|
||||
msgid "Attempted heap allocation when MicroPython VM not running.\n"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "Auto-reload is off.\n"
|
||||
msgstr "Auto-reload be off.\n"
|
||||
|
|
|
@ -9,7 +9,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-03-08 12:45-0800\n"
|
||||
"POT-Creation-Date: 2019-03-12 11:17-0700\n"
|
||||
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
@ -294,6 +294,10 @@ msgstr ""
|
|||
msgid "Array values should be single bytes."
|
||||
msgstr "Valores del array deben ser bytes individuales."
|
||||
|
||||
#: supervisor/shared/safe_mode.c
|
||||
msgid "Attempted heap allocation when MicroPython VM not running.\n"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "Auto-reload is off.\n"
|
||||
msgstr "Auto-recarga deshabilitada.\n"
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-03-08 12:45-0800\n"
|
||||
"POT-Creation-Date: 2019-03-12 11:17-0700\n"
|
||||
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
|
||||
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
|
||||
"Language-Team: fil\n"
|
||||
|
@ -291,6 +291,10 @@ msgstr "May halfwords (type 'H') dapat ang array"
|
|||
msgid "Array values should be single bytes."
|
||||
msgstr "Array values ay dapat single bytes."
|
||||
|
||||
#: supervisor/shared/safe_mode.c
|
||||
msgid "Attempted heap allocation when MicroPython VM not running.\n"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "Auto-reload is off.\n"
|
||||
msgstr "Awtomatikong pag re-reload ay OFF.\n"
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: 0.1\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-03-08 12:45-0800\n"
|
||||
"POT-Creation-Date: 2019-03-12 11:17-0700\n"
|
||||
"PO-Revision-Date: 2018-12-23 20:05+0100\n"
|
||||
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
|
||||
"Language-Team: fr\n"
|
||||
|
@ -292,6 +292,10 @@ msgstr "Le tableau doit contenir des halfwords (type 'H')"
|
|||
msgid "Array values should be single bytes."
|
||||
msgstr "Les valeurs du tableau doivent être des octets simples 'bytes'."
|
||||
|
||||
#: supervisor/shared/safe_mode.c
|
||||
msgid "Attempted heap allocation when MicroPython VM not running.\n"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "Auto-reload is off.\n"
|
||||
msgstr "Auto-rechargement désactivé.\n"
|
||||
|
|
|
@ -9,7 +9,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-03-08 12:45-0800\n"
|
||||
"POT-Creation-Date: 2019-03-12 11:17-0700\n"
|
||||
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
|
||||
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
|
||||
"Language-Team: \n"
|
||||
|
@ -290,6 +290,10 @@ msgstr ""
|
|||
msgid "Array values should be single bytes."
|
||||
msgstr ""
|
||||
|
||||
#: supervisor/shared/safe_mode.c
|
||||
msgid "Attempted heap allocation when MicroPython VM not running.\n"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "Auto-reload is off.\n"
|
||||
msgstr "Auto-reload disattivato.\n"
|
||||
|
|
|
@ -9,7 +9,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-03-08 12:45-0800\n"
|
||||
"POT-Creation-Date: 2019-03-12 11:17-0700\n"
|
||||
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
@ -290,6 +290,10 @@ msgstr "Array deve conter meias palavras (tipo 'H')"
|
|||
msgid "Array values should be single bytes."
|
||||
msgstr ""
|
||||
|
||||
#: supervisor/shared/safe_mode.c
|
||||
msgid "Attempted heap allocation when MicroPython VM not running.\n"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "Auto-reload is off.\n"
|
||||
msgstr "A atualização automática está desligada.\n"
|
||||
|
|
3
main.c
3
main.c
|
@ -139,8 +139,7 @@ void stop_mp(void) {
|
|||
MP_STATE_VM(vfs_cur) = vfs;
|
||||
#endif
|
||||
|
||||
// Run any finalizers before we stop using the heap.
|
||||
gc_sweep_all();
|
||||
gc_deinit();
|
||||
}
|
||||
|
||||
#define STRING_LIST(...) {__VA_ARGS__, ""}
|
||||
|
|
13
py/gc.c
13
py/gc.c
|
@ -31,6 +31,8 @@
|
|||
#include "py/gc.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "supervisor/shared/safe_mode.h"
|
||||
|
||||
#if MICROPY_ENABLE_GC
|
||||
|
||||
#if MICROPY_DEBUG_VERBOSE // print debugging info
|
||||
|
@ -182,6 +184,13 @@ void gc_init(void *start, void *end) {
|
|||
DEBUG_printf(" pool at %p, length " UINT_FMT " bytes, " UINT_FMT " blocks\n", MP_STATE_MEM(gc_pool_start), gc_pool_block_len * BYTES_PER_BLOCK, gc_pool_block_len);
|
||||
}
|
||||
|
||||
void gc_deinit() {
|
||||
// Run any finalizers before we stop using the heap.
|
||||
gc_sweep_all();
|
||||
|
||||
MP_STATE_MEM(gc_pool_start) = 0;
|
||||
}
|
||||
|
||||
void gc_lock(void) {
|
||||
GC_ENTER();
|
||||
MP_STATE_MEM(gc_lock_depth)++;
|
||||
|
@ -463,6 +472,10 @@ void *gc_alloc(size_t n_bytes, bool has_finaliser, bool long_lived) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (MP_STATE_MEM(gc_pool_start) == 0) {
|
||||
reset_into_safe_mode(GC_ALLOC_OUTSIDE_VM);
|
||||
}
|
||||
|
||||
GC_ENTER();
|
||||
|
||||
// check if GC is locked
|
||||
|
|
1
py/gc.h
1
py/gc.h
|
@ -32,6 +32,7 @@
|
|||
#include "py/misc.h"
|
||||
|
||||
void gc_init(void *start, void *end);
|
||||
void gc_deinit(void);
|
||||
|
||||
// These lock/unlock functions can be nested.
|
||||
// They can be used to prevent the GC from allocating/freeing.
|
||||
|
|
|
@ -105,7 +105,7 @@ void print_safe_mode_message(safe_mode_t reason) {
|
|||
if (reason != NO_SAFE_MODE) {
|
||||
serial_write("\r\n");
|
||||
serial_write_compressed(translate("You are running in safe mode which means something unanticipated happened.\n"));
|
||||
if (reason == HARD_CRASH || reason == MICROPY_NLR_JUMP_FAIL || reason == MICROPY_FATAL_ERROR) {
|
||||
if (reason == HARD_CRASH || reason == MICROPY_NLR_JUMP_FAIL || reason == MICROPY_FATAL_ERROR || reason == GC_ALLOC_OUTSIDE_VM) {
|
||||
serial_write_compressed(translate("Looks like our core CircuitPython code crashed hard. Whoops!\nPlease file an issue at https://github.com/adafruit/circuitpython/issues\n with the contents of your CIRCUITPY drive and this message:\n"));
|
||||
if (reason == HARD_CRASH) {
|
||||
serial_write_compressed(translate("Crash into the HardFault_Handler.\n"));
|
||||
|
@ -113,6 +113,8 @@ void print_safe_mode_message(safe_mode_t reason) {
|
|||
serial_write_compressed(translate("MicroPython NLR jump failed. Likely memory corruption.\n"));
|
||||
} else if (reason == MICROPY_FATAL_ERROR) {
|
||||
serial_write_compressed(translate("MicroPython fatal error.\n"));
|
||||
} else if (reason == GC_ALLOC_OUTSIDE_VM) {
|
||||
serial_write_compressed(translate("Attempted heap allocation when MicroPython VM not running.\n"));
|
||||
}
|
||||
} else if (reason == BROWNOUT) {
|
||||
serial_write_compressed(translate("The microcontroller's power dipped. Please make sure your power supply provides\nenough power for the whole circuit and press reset (after ejecting CIRCUITPY).\n"));
|
||||
|
|
|
@ -35,7 +35,8 @@ typedef enum {
|
|||
HEAP_OVERWRITTEN,
|
||||
MANUAL_SAFE_MODE,
|
||||
MICROPY_NLR_JUMP_FAIL,
|
||||
MICROPY_FATAL_ERROR
|
||||
MICROPY_FATAL_ERROR,
|
||||
GC_ALLOC_OUTSIDE_VM
|
||||
} safe_mode_t;
|
||||
|
||||
safe_mode_t wait_for_safe_mode_reset(void);
|
||||
|
|
Loading…
Reference in New Issue