From 13994ed823c2445bbeecea677fd604744b373c5e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 29 Jul 2021 07:51:02 -0700 Subject: gc: problem in several object copying functions. The functions copy-cons, copy-tree, copy-fun and copy-tnode have a problem. They copy the original object bitwise with a structure assignment, and then make some adjustments. The problem is that this inappropriately copies the object's metadata related to gc, such as its generation number or finalization count. To fix this, we introduce a copy_obj function, which is a companion to make_obj. This performs a shallow copy of an object without incorrectly propagating inappropriate metadata. * gc.c, gc.h (copy_obj): New function. * lib.c (copy_fun, copy_cons, copy_tree): Use copy_obj, instead of make_obj plus structure assignment. * tree.c (copy_tnode): Likewise. --- gc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'gc.h') diff --git a/gc.h b/gc.h index 309a8912..00c616e9 100644 --- a/gc.h +++ b/gc.h @@ -30,6 +30,7 @@ void gc_late_init(void); val prot1(val *loc); void protect(val *, ...); val make_obj(void); +val copy_obj(val); void gc(void); int gc_state(int); int gc_inprogress(void); -- cgit v1.2.3