lua-users home
lua-l archive

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


Will there be a forthcoming 5.0.3 to fix this and any other known bugs? I use the LuaBinaries and don't want to compile my own version unless necessary.

Thanks,

Tom Reahard

Roberto Ierusalimschy wrote:

There seems to be a stupid bug in the collection of weak tables in Lua
5.0.2. Once a weak table survives a garbage collection, it is never
collected. A simple example is like this:

 a = {}
 print(gcinfo())
 for i = 1, 10000 do
   a[i] = setmetatable({}, {__mode = "v"})
 end
 collectgarbage()
 a = nil
 collectgarbage()
 print(gcinfo())     -- should be near the first value...


The patch is a single line in lgc.c:

@@ -366,7 +366,7 @@
  GCObject *curr;
  int count = 0;  /* number of collected items */
  while ((curr = *p) != NULL) {
-    if (curr->gch.marked > limit) {
+    if ((curr->gch.marked & ~(KEYWEAK | VALUEWEAK)) > limit) {
      unmark(curr);
      p = &curr->gch.next;
    }

(Bug reported by Chromix.)

As far as we checked, this bug is not present in Lua 5.1 beta.

-- Roberto