lua-users home
lua-l archive

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

I've got a patch that appears to have fixed the bug; however, I have
not tested it extensively.  I'm new to the internals of the Lua
interpreter, so I may have missed some unintended side effects.  My
understanding is that during the mark phase of the GC, the upvalue
references are never visited directly.  They are only visited when the
stack of the currently running thread is traversed.  Since the thread
objects that were created in the code I posted only were referenced
through through an upvalue on the thread's stack, they were never
marked.  (Correct me if I'm wrong, Roberto.)

My two worries with this patch are memory leaks and infinite loops. 
The tests I have run with this change show that these things are not

diff -ur lua-5.0.2/src/lgc.c lua-5.0.2-bugfix/src/lgc.c
--- lua-5.0.2/src/lgc.c 2003-10-01 07:30:00.000000000 -0600
+++ lua-5.0.2-bugfix/src/lgc.c  2005-01-03 10:46:18.000000000 -0700
@@ -218,10 +218,8 @@
     markvalue(st, cl->l.p);
     for (i=0; i<cl->l.nupvalues; i++) {  /* mark its upvalues */
       UpVal *u = cl->l.upvals[i];
-      if (!u->marked) {
-        markobject(st, &u->value);
-        u->marked = 1;
-      }
+      markobject(st, u->v);
+      u->marked = 1;

On Mon, 03 Jan 2005 11:20:44 -0200, Roberto Ierusalimschy
<> wrote:
> I found the bug, but I still do not have a fix. (If someone wants an
> explanation about the bug, just ask.)
> -- Roberto