aboutsummaryrefslogtreecommitdiff
path: root/py/gc.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-12-08 00:10:44 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-12-08 00:10:44 +0200
commit9ef4be8b41c7d256908ba319918c0f7d54346bf4 (patch)
tree8be15e01025fa3d462fb99db890efcc83458c375 /py/gc.c
parent9ebc037eee575fd951dea92c82ed9704d9101924 (diff)
py/gc: Add CLEAR_ON_SWEEP option to debug mis-traced objects.
Accessing them will crash immediately instead still working for some time, until overwritten by some other data, leading to much less deterministic crashes.
Diffstat (limited to 'py/gc.c')
-rw-r--r--py/gc.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/py/gc.c b/py/gc.c
index 172a5e8fc..9a3c57e61 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -44,6 +44,10 @@
// make this 1 to dump the heap each time it changes
#define EXTENSIVE_HEAP_PROFILING (0)
+// make this 1 to zero out swept memory to more eagerly
+// detect untraced object still in use
+#define CLEAR_ON_SWEEP (0)
+
#define WORDS_PER_BLOCK ((MICROPY_BYTES_PER_GC_BLOCK) / BYTES_PER_WORD)
#define BYTES_PER_BLOCK (MICROPY_BYTES_PER_GC_BLOCK)
@@ -286,6 +290,9 @@ STATIC void gc_sweep(void) {
case AT_TAIL:
if (free_tail) {
ATB_ANY_TO_FREE(block);
+ #if CLEAR_ON_SWEEP
+ memset((void*)PTR_FROM_BLOCK(block), 0, BYTES_PER_BLOCK);
+ #endif
}
break;