From 7b6473d3895c94397206913937e93b1aad48952e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 22 Mar 2018 06:54:53 -0700 Subject: gc bugs: incorrect struct init function assignments. * struct.c (struct_set_initfun, struct_set_postinitfun): Replace incorrect direct assignments with set macro. This manifested itself as corruption. I ran into a situation in which the postinitfun of a struct type was prematurely reclaimed and the heap object was re-used for something else wreaking havoc on the postinit call when the struct was instantiated. --- struct.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'struct.c') diff --git a/struct.c b/struct.c index 8c104d08..5f614af2 100644 --- a/struct.c +++ b/struct.c @@ -406,7 +406,7 @@ val struct_get_initfun(val type) val struct_set_initfun(val type, val fun) { struct struct_type *st = stype_handle(&type, lit("struct-set-initfun")); - st->initfun = fun; + set(mkloc(st->initfun, type), fun); return fun; } @@ -419,7 +419,7 @@ val struct_get_postinitfun(val type) val struct_set_postinitfun(val type, val fun) { struct struct_type *st = stype_handle(&type, lit("struct-set-postinitfun")); - st->postinitfun = fun; + set(mkloc(st->postinitfun, type), fun); return fun; } -- cgit v1.2.3