summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-06-19 06:41:04 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-06-19 06:41:04 -0700
commitee639342a87cbb1db085f58f5f57cb2085832173 (patch)
treeeee4fad0883ba471f5fc1d030a3e323d7e1130ca
parent5b0d68a85dd9e9dca020ac4bfbbcf72cf8347a2b (diff)
downloadtxr-ee639342a87cbb1db085f58f5f57cb2085832173.tar.gz
txr-ee639342a87cbb1db085f58f5f57cb2085832173.tar.bz2
txr-ee639342a87cbb1db085f58f5f57cb2085832173.zip
make-struct-type: fix far-fetched gc/stability issue.
* struct.c (make_struct_type): The length and plus operations can cons if the number of static slots doesn't fit into a fixnum. Let's move that operation out of the sensitive object construction region.
-rw-r--r--struct.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/struct.c b/struct.c
index 2374a612..604ba041 100644
--- a/struct.c
+++ b/struct.c
@@ -309,11 +309,11 @@ val make_struct_type(val name, val super,
val id = num_fast(coerce(ucnum, st) / (uptopow2(sizeof *st) / 2));
val super_slots = if2(su, su->slots);
val all_slots = uniq(append2(super_slots, append2(static_slots, slots)));
+ cnum stsl_upb = c_num(plus(length(static_slots),
+ num(if3(su, su->nstslots, 0))));
val stype = cobj(coerce(mem_t *, st), struct_type_s, &struct_type_ops);
val iter;
cnum sl, stsl;
- cnum stsl_upb = c_num(plus(length(static_slots),
- num(if3(su, su->nstslots, 0))));
struct stslot null_ptr = { nil, 0, 0, nil };
st->self = stype;