diff --git a/src/vm/wren_value.c b/src/vm/wren_value.c index c49a3b6b..6a38193f 100644 --- a/src/vm/wren_value.c +++ b/src/vm/wren_value.c @@ -1089,6 +1089,9 @@ static void blackenFn(WrenVM* vm, ObjFn* fn) // Mark the constants. wrenGrayBuffer(vm, &fn->constants); + // Mark the module it belongs to, in case it's been unloaded. + wrenGrayObj(vm, fn->module); + // Keep track of how much memory is still in use. vm->bytesAllocated += sizeof(ObjFn); vm->bytesAllocated += sizeof(uint8_t) * fn->code.capacity;