[CM] Possible bug with c-object & openlet

Christos Vagias chris.actondev at gmail.com
Mon Dec 20 06:24:10 PST 2021


Oops, had attached the wrong file, apologies!


On Mon, 20 Dec 2021 at 15:45, Christos Vagias <chris.actondev at gmail.com>
wrote:

> Hi Bil,
>
> I think I found a bug:
> When creating an object with
>
>   s7_pointer obj = s7_make_c_object(sc, type_foo, new Foo{});
>   s7_pointer methods = s7_eval_c_string(
>       sc, "(inlet :write foo-write))");
>   // Without gc_protect the c_object loses its methods after gc
>   if(arg_gc_protect == 1) s7_gc_protect(sc, methods);
>   s7_c_object_set_let(sc, obj, methods);
>   return s7_openlet(sc, obj);
>
> (as the comment says) without gc_protect of the c_object let/methods, the
> c_object loses its methods after gc.
> I'd assume that since we "set_let" to a value that still is "alive", it's
> "let/methods objects" would also not be garbage collected (at least I
> assume that the let is getting gc'ed).
>
> I'm attaching a demo program
> - ./main 0 # no gc_protect, errors
> - ./main 1 # gc_protect, no errors
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20211220/645d26d1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug-c-object-openlet.zip
Type: application/zip
Size: 1706 bytes
Desc: not available
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20211220/645d26d1/attachment.zip>


More information about the Cmdist mailing list