lua-users home
lua-l archive

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


> On 13/10/2011 10:54, Ingo van Lil wrote:
> 
> >I'm currently hunting a bug in our project where the LUA garbage
> >collector occasionally frees one particular Proto object although it is
> >still reachable and in use. I've now managed to come up with a small
> >example demonstrating the problem.
> 
> Some more information: I believe I've identified the culprit to be
> the luaC_checkGC() call introduced by item 6 of the 5.1.4 patches on
> http://www.lua.org/bugs.html. Just before the interpreter runs into
> the assertion failure this call sweeps the string table during the
> anchor_token() call in lparser.c:379. If I remove the checkGC() call
> my scripts run stable again.

You are right. The problem seems to be this sequence
in close_func (lparser.c):

  L->top -= 2;  /* remove table and prototype from the stack */
  /* last token read was anchored in defunct function; must reanchor it */
  if (fs) anchor_token(ls);

Up to this point, the prototype is anchored in the stack. But after the
"L->top -= 2", the prototype is unanchored; anchor_token may call the
collector, which then may collect the proto.

I believe the fix is simply to change the order of these two lines. But
I will have a closer look. (There is some distance between this point
where the prototype is unanchored to where it is anchored again, in
'pushclosure'.)

-- Roberto