summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2019-12-10 17:05:47 -0600
committerJeff Epler <jepler@gmail.com>2019-12-10 17:07:52 -0600
commit6305d489475f0eb91b0fba59fd93fc72191a28eb (patch)
treee4316032de03dd191cc5341a104650f15e7fb9b0 /py
parentf4a5c17b5e79cf9bd02be248620d445065891a25 (diff)
gc_free: give a better error when freeing outside of VM
Diffstat (limited to 'py')
-rwxr-xr-xpy/gc.c3
1 files changed, 3 insertions, 0 deletions
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);