From 6d865f2acdf5f93f06ddd0f4d3ac3a450d36dcd7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 2 Sep 2015 07:32:43 -0700 Subject: Fix incorrect finalization of struct-type. The issue is that we can't call remhash in the cobj destroy handler, because we are in the middle of gc. The fix is to register a proper finalization hook. This is the first use of finalize from within TXR. * gc.c (gc_finalize): static becomes extern. * gc.h (gc_finalize): Declared. * struct.c (struct_type_finalize_f): New static variable. (struct_init): GC-protect new static variable, and initialize it to point to new struct_type_finalize function. (struct_type_finalize): New function: performs the remhash calls previously done in struct_type_free. (make_struct_type): Register a finalizer hook for every new structure type, which will call struct_type_finalize. (struct_type_free): Static function removed. (struct_type_ops): Use generic cobj_destroy_free_op since all that is left to do is to free the handle. --- gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gc.c') diff --git a/gc.c b/gc.c index d0f99aaa..d524c984 100644 --- a/gc.c +++ b/gc.c @@ -807,7 +807,7 @@ static val gc_wrap(void) return nil; } -static val gc_finalize(val obj, val fun) +val gc_finalize(val obj, val fun) { type_check(fun, FUN); -- cgit v1.2.3