lua-users home
lua-l archive

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


>  Bruce> While working on a project, I encountered what I think is a bug
>  Bruce> in Lua 5.4-work2's generational garbage collection as it
>  Bruce> interacts with LPEG.
> 
> A while back (July?) I posted an analysis of a bug in work2's
> generational GC that applied to all uses of the uservalue slots of
> userdata objects. I haven't checked that this is the same bug, but I'd
> bet that it is; the issue is easily triggered with the 're' module of
> LPEG.
> 
> Roberto is aware of it, so I guess we can hope for it to be fixed in
> work3 or whatever the next release is.

I guess this fixes the bug (following Gierth's analysis):

In lgc.c:

 static int traverseudata (global_State *g, Udata *u) {
   int i;
   markobjectN(g, u->metatable);  /* mark its metatable */
   for (i = 0; i < u->nuvalue; i++)
     markvalue(g, &u->uv[i].uv);
+  if (g->gckind == KGC_GEN) {
+    linkgclist(u, g->grayagain);  /* keep it in some gray list */
+    black2gray(u);
+  }
   return 1 + u->nuvalue;
 }

-- Roberto