summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--locale/ID.po6
-rw-r--r--locale/circuitpython.pot6
-rw-r--r--locale/de_DE.po6
-rw-r--r--locale/en_US.po6
-rw-r--r--locale/en_x_pirate.po6
-rw-r--r--locale/es.po6
-rw-r--r--locale/fil.po6
-rw-r--r--locale/fr.po6
-rw-r--r--locale/it_IT.po6
-rw-r--r--locale/pt_BR.po6
-rwxr-xr-xmain.c3
-rwxr-xr-xpy/gc.c13
-rw-r--r--py/gc.h1
-rw-r--r--supervisor/shared/safe_mode.c4
-rw-r--r--supervisor/shared/safe_mode.h3
15 files changed, 70 insertions, 14 deletions
diff --git a/locale/ID.po b/locale/ID.po
index 065043890..8961872a0 100644
--- a/locale/ID.po
+++ b/locale/ID.po
@@ -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"
diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot
index c0b460c0e..36975f988 100644
--- a/locale/circuitpython.pot
+++ b/locale/circuitpython.pot
@@ -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 ""
diff --git a/locale/de_DE.po b/locale/de_DE.po
index b50899d7c..1a73ec7a2 100644
--- a/locale/de_DE.po
+++ b/locale/de_DE.po
@@ -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"
diff --git a/locale/en_US.po b/locale/en_US.po
index f98f42eeb..52d4b73e8 100644
--- a/locale/en_US.po
+++ b/locale/en_US.po
@@ -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 ""
diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po
index 5382c93f2..6597d98bd 100644
--- a/locale/en_x_pirate.po
+++ b/locale/en_x_pirate.po
@@ -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"
diff --git a/locale/es.po b/locale/es.po
index 8c2b31c5a..a6749413d 100644
--- a/locale/es.po
+++ b/locale/es.po
@@ -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"
diff --git a/locale/fil.po b/locale/fil.po
index cb58f2be2..2d9ce796b 100644
--- a/locale/fil.po
+++ b/locale/fil.po
@@ -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"
diff --git a/locale/fr.po b/locale/fr.po
index 11ca7a261..eeab87b65 100644
--- a/locale/fr.po
+++ b/locale/fr.po
@@ -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"
diff --git a/locale/it_IT.po b/locale/it_IT.po
index b3e411cfd..22bc8ed4b 100644
--- a/locale/it_IT.po
+++ b/locale/it_IT.po
@@ -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"
diff --git a/locale/pt_BR.po b/locale/pt_BR.po
index 415bb0b4c..77e1beff6 100644
--- a/locale/pt_BR.po
+++ b/locale/pt_BR.po
@@ -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"
diff --git a/main.c b/main.c
index f0913db6e..4b58b778d 100755
--- a/main.c
+++ b/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__, ""}
diff --git a/py/gc.c b/py/gc.c
index 1f5cd8d01..e0b77c4cf 100755
--- a/py/gc.c
+++ b/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
diff --git a/py/gc.h b/py/gc.h
index 64f4b0d17..c05e006b4 100644
--- a/py/gc.h
+++ b/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.
diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c
index c1ce1fc9c..3bb75b897 100644
--- a/supervisor/shared/safe_mode.c
+++ b/supervisor/shared/safe_mode.c
@@ -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"));
diff --git a/supervisor/shared/safe_mode.h b/supervisor/shared/safe_mode.h
index eba2668ac..59480b55b 100644
--- a/supervisor/shared/safe_mode.h
+++ b/supervisor/shared/safe_mode.h
@@ -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);