diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-10-21 07:14:34 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-10-21 07:14:34 -0700 |
commit | 21f800ed2d5adb542a931d50dc1f5abaaae9a2d3 (patch) | |
tree | a69b3b1c5fcca134ccec98b5ba923b123d05b02b | |
parent | 5b7d98ead12b4760fe764640e3ec91e358843384 (diff) | |
download | txr-21f800ed2d5adb542a931d50dc1f5abaaae9a2d3.tar.gz txr-21f800ed2d5adb542a931d50dc1f5abaaae9a2d3.tar.bz2 txr-21f800ed2d5adb542a931d50dc1f5abaaae9a2d3.zip |
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.
-rw-r--r-- | struct.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -33,6 +33,7 @@ #include <stdlib.h> #include <limits.h> #include <signal.h> +#include <assert.h> #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); } } |