From 6305d489475f0eb91b0fba59fd93fc72191a28eb Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 10 Dec 2019 17:05:47 -0600 Subject: gc_free: give a better error when freeing outside of VM --- py/gc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'py') diff --git a/py/gc.c b/py/gc.c index a8a5fde12..5e631f5ed 100755 --- a/py/gc.c +++ b/py/gc.c @@ -667,6 +667,9 @@ void gc_free(void *ptr) { if (ptr == NULL) { GC_EXIT(); } else { + if (MP_STATE_MEM(gc_pool_start) == 0) { + reset_into_safe_mode(GC_ALLOC_OUTSIDE_VM); + } // get the GC block number corresponding to this pointer assert(VERIFY_PTR(ptr)); size_t block = BLOCK_FROM_PTR(ptr); -- cgit v1.2.3