[CM] Possible bug with c-object & openlet

Christos Vagias chris.actondev at gmail.com
Mon Dec 20 05:45:11 PST 2021


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/9a59238f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug-cc.zip
Type: application/zip
Size: 1622 bytes
Desc: not available
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20211220/9a59238f/attachment.zip>


More information about the Cmdist mailing list