summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-03-22 06:54:53 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-03-22 06:54:53 -0700
commitb4e2a549609f3c977beed817a5a615af358414b7 (patch)
tree7f36a136ee1b2a3b8d8032d948d61e05a707851a
parent9c804b7087e9b332b2cea738fbda493abd36fa1b (diff)
downloadtxr-b4e2a549609f3c977beed817a5a615af358414b7.tar.gz
txr-b4e2a549609f3c977beed817a5a615af358414b7.tar.bz2
txr-b4e2a549609f3c977beed817a5a615af358414b7.zip
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.
-rw-r--r--struct.c4
1 files changed, 2 insertions, 2 deletions
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;
}