[Ecls-list] Trivial-Garbage: weak pointers in ECL

Alexander Gavrilov angavrilov at gmail.com
Sat Apr 3 09:11:59 UTC 2010


> > ECL has had weak pointers since September,
> > so here is a patch that adds them to tg
> 
> ECL (compiled from the git repository a few minutes ago) seems to hang
> when running the test suite. I didn't investigate why. I've pushed
> your patch anyway, but will make a release only after this issue is
> resolved. Thanks!

In my case it simply crashed. It seems that initializing
weak links with non-pointer immediates breaks GC.

This appears to fix it:

@@ -1326,19 +1326,21 @@ ecl_alloc_weak_pointer(cl_object o)
 	ecl_disable_interrupts_env(the_env);
 	obj = GC_MALLOC_ATOMIC(sizeof(struct ecl_weak_pointer));
 	ecl_enable_interrupts_env(the_env);
 	obj->t = t_weak_pointer;
 	obj->value = o;
-	GC_general_register_disappearing_link(&(obj->value), (void*)o);
+	if (!FIXNUMP(o) && !CHARACTERP(o)) {
+		GC_general_register_disappearing_link(&(obj->value), (void*)o);
+		si_set_finalizer(obj, Ct);
+	}
 	return (cl_object)obj;
 }
 
 cl_object
 si_make_weak_pointer(cl_object o)
 {
 	cl_object pointer = ecl_alloc_weak_pointer(o);
-        si_set_finalizer(pointer, Ct);
 	@(return pointer);
 }
 
 static cl_object
 ecl_weak_pointer_value(cl_object o)





More information about the ecl-devel mailing list