diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-06-19 06:42:59 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-06-19 06:42:59 -0700 |
commit | 95d5b41266ca3cd40dcd948ecad06d570be32812 (patch) | |
tree | f0d8860d3838051d7c48e0490ae1c32ec3b75a26 /lib.c | |
parent | ee639342a87cbb1db085f58f5f57cb2085832173 (diff) | |
download | txr-95d5b41266ca3cd40dcd948ecad06d570be32812.tar.gz txr-95d5b41266ca3cd40dcd948ecad06d570be32812.tar.bz2 txr-95d5b41266ca3cd40dcd948ecad06d570be32812.zip |
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.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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; } |