From 95d5b41266ca3cd40dcd948ecad06d570be32812 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 19 Jun 2019 06:42:59 -0700 Subject: packages: generational gc bug. * lib.c (make_package_common): The way the two hashes are assigned into the new package here is not correct. The problem is that the first make_hash can trigger gc. Then it is possible that the package object will move into the mature generation, after which the assignment of the second package is a wrong-way assignment requiring the set macro. Instead of bringing in that macro, the obvious way to solve it is to just allocate the hashes first, and then the package: exactly the way we build a cons cell from existing values. --- lib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index f1740e52..12863cf3 100644 --- a/lib.c +++ b/lib.c @@ -4940,13 +4940,13 @@ val gensym(val prefix) static val make_package_common(val name) { + val sh = make_hash(nil, nil, lit("t")); /* don't have t yet! */ + val hh = make_hash(nil, nil, lit("t")); val obj = make_obj(); obj->pk.type = PKG; obj->pk.name = name; - obj->pk.symhash = nil; /* make_hash calls below could trigger gc! */ - obj->pk.hidhash = nil; - obj->pk.symhash = make_hash(nil, nil, lit("t")); /* don't have t yet! */ - obj->pk.hidhash = make_hash(nil, nil, lit("t")); + obj->pk.symhash = sh; + obj->pk.hidhash = hh; return obj; } -- cgit v1.2.3