From f9f357f060b6c084c720b67226af3ad6f4cbfff7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 28 Jul 2019 15:29:10 -0700 Subject: FFI: bugfix: GC-correctness of assignments. Recent work has introduced wrong-way assignments. When we compile the slots after we have created the type object, the slot types may be in a newer generation than the type object. If we are reusing an old type object, it can be older than the syntax, or the Lisp object being stored in it. * ffi.c (make_ffi_type_struct, make_ffi_type_union): add some setcheck calls to handle anti-generational assignments. --- ffi.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ffi.c b/ffi.c index 450bc904..0b426703 100644 --- a/ffi.c +++ b/ffi.c @@ -2882,6 +2882,9 @@ static val make_ffi_type_struct(val syntax, val lisp_type, tft->incomplete = 1; + setcheck(obj, syntax); + setcheck(obj, lisp_type); + sethash(ffi_struct_tag_hash, cadr(syntax), obj); for (i = 0; i < nmemb; i++) { @@ -2897,6 +2900,9 @@ static val make_ffi_type_struct(val syntax, val lisp_type, memb[i].mname = slot; memb[i].mtft = mtft; + setcheck(obj, slot); + setcheck(obj, type); + if (mtft->bitfield) { ucnum size = mtft->size; ucnum bits_type = 8 * size; @@ -3045,6 +3051,8 @@ static val make_ffi_type_union(val syntax, val use_existing, val self) tft->incomplete = 1; + setcheck(obj, syntax); + sethash(ffi_struct_tag_hash, cadr(syntax), obj); for (i = 0; i < nmemb; i++) { @@ -3058,6 +3066,9 @@ static val make_ffi_type_union(val syntax, val use_existing, val self) memb[i].mtft = mtft; memb[i].offs = 0; + setcheck(obj, slot); + setcheck(obj, type); + if (most_align < (ucnum) mtft->align) most_align = mtft->align; -- cgit v1.2.3