lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2011/9/16 Roberto Ierusalimschy <roberto@inf.puc-rio.br>:
>> I'm very sad that nobody reply my last post[1], even Roberto didn't.
>> [...]
>
> As you want some comment, I will give a brief comment regarding your
> implementation. I guess there is a little "bug" in the garbage
> collection of your userdata. Consider your patch:
>
> *** 248,254 ****
>      case LUA_TUSERDATA: {
>        Table *mt = gco2u(o)->metatable;
>        markobject(g, mt);
> !       markobject(g, gco2u(o)->env);
>        gray2black(o);  /* all pointers marked */
>        return;
>      }
> --- 248,259 ----
>      case LUA_TUSERDATA: {
>        Table *mt = gco2u(o)->metatable;
>        markobject(g, mt);
> !       if (gco2u(o)->valuecount != 0)
> !       {
> !         int i, len = gco2u(o)->valuecount;
> !         for (i = 0; i < len; ++i)
> !           markobject(g, &gco2u(o)->values[i]);    <<<<<
> !       }
>        gray2black(o);  /* all pointers marked */
>        return;
>      }
>
> In the original version, the call to 'markobject' was always over
> a table, and so we knew the recursion would stop at that level
> (the 'reallymarkobject' for tables only queues the table for later
> traversal). In your version, the call to 'markobject' (see '<<<<') may
> be marking any object, in particular another userdata. So, it seems
> that a long linked list of userdata could force an unlimited depth of
> recursive calls to 'reallymarkobject', eventually crashing the C stack.
>
> (BTW, as you can now have any value as userdata, it seems that you
> should use 'markvalue' instead of 'markobject' in the line marked
> with '<<<<'.)
>
> -- Roberto
>
>

Thank you for you comment :)

As you say, I need to take more attention to the garbage part of
language :( I will try to understand it. But, what I most what to know
is about this idea, can this idea be merge into Lua 5.2? Or any other
implement of tuple (not only with userdata) can be merge to Lua 5.2?
Is there any plans to do this? Just interesting with this topic :)

Thank you again for reading my patch, Roberto.