From ee639342a87cbb1db085f58f5f57cb2085832173 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 19 Jun 2019 06:41:04 -0700 Subject: 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. --- struct.c | 4 ++-- 1 file 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; -- cgit v1.2.3