From 21f800ed2d5adb542a931d50dc1f5abaaae9a2d3 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 21 Oct 2016 07:14:34 -0700 Subject: struct bug: mismanagement of static slot store. The bug_unless statement was found to go off, indicating an internal problem. Indeed, the store of inherited static slots were being set to non-nil by incorrect copying in two places. This is harmless in and of itself; it's just a way of being tidy. If a slot's value is located elsewhere, then the local store must be nil. * struct.c (static_slot_home_fixup): After fetching a fresh copy of the home type's stslot entry, clear the store to nil. (make_struct_type): Likewise. (struct_type_mark): Use assert for this rather than bug_unless, because it happens in the middle of garbage collection. Throwing an exception out of the middle of gc is a nonstarter. --- struct.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'struct.c') diff --git a/struct.c b/struct.c index cfa3c3b8..c3d7293e 100644 --- a/struct.c +++ b/struct.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "config.h" #include ALLOCA_H #include "lib.h" @@ -220,6 +221,7 @@ static void static_slot_home_fixup(struct struct_type *st) struct struct_type *shome = coerce(struct struct_type *, s->home_type->co.handle); *s = shome->stslot[s->home_offs]; + s->store = nil; } } } @@ -311,6 +313,7 @@ val make_struct_type(val name, val super, ss->store = if2(msl, stslot_place(&su->stslot[m])); } else { *ss = su->stslot[m]; + ss->store = nil; } sethash(slot_hash, cons(slot, id), num(n + STATIC_SLOT_BASE)); } else { @@ -408,7 +411,7 @@ static void struct_type_mark(val obj) if (sl->home_type == st->self) gc_mark(sl->store); else - bug_unless (sl->store == nil); + assert (sl->store == nil); } } -- cgit v1.2.3