From c75baad41d9e6cbe11d83e208ccfe35c18a6b19d Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 24 May 2017 07:21:30 -0700 Subject: ffi: sanity check on object in ffi_val_get. * ffi.c (ffi_val_get): Throw an exception if the object doesn't appear valid. * gc.c (valid_object_p): New function. Invalid objects are those that are pointers, but either not into a heap, or else to a freed object or to an object that is marked by the garbage collector (should only be seen while GC is running). All others are valid. There can be false positives here: a value with the LIT tag is in fact a pointer, but we don't check whether that is valid. * gc.c (valid_object_p): Declared. * txr.1: Remarks added to documentation of FFI val type. --- gc.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gc.h') diff --git a/gc.h b/gc.h index 1e67e723..326c5f87 100644 --- a/gc.h +++ b/gc.h @@ -47,6 +47,8 @@ val gc_mutated(val); extern int full_gc; #endif +val valid_object_p(val obj); + void unmark(void); void gc_cancel(void); void gc_hint_func(val *); -- cgit v1.2.3