Ruby Forum Ruby-core > patch

Posted by Roger Pack (rogerdpack)
on 30.04.2008 22:25
Attachment: unleak.diff (442 Bytes)
(Received via mailing list)
It said on the web site to throw ones patches this direction.

Here's one for a bug submitted [and fixed] about 6 months ago.  Guess
I forgot to submit the patch itself.
This is a fix for the following leaks:

def leak
 "name".split(/::/)
end

loop {leak} # leaks

def grow
 for i in 1..100
   eval "b#{i}=1"
 end
end
1500000.times {grow} # leaks
[this style of leak is reported on several web sites as a ruby leak, as 
well]

Ref:
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=15425&group_id=426

Reservations:
I just added this patch from someone else's post--I'm not positive
there aren't side-effects, though I haven't seen any.  I'm not scope
pro here :)
Also for some reason this worked on my Linux machine but not my mac
machine [still leaks].  Maybe because of my linking to some old
'legacy' libs or something.
Let me know what I can do to help it get accepted.
-R

PS Here's a copy in case the attachment doesn't get through.
Index: parse.y
===================================================================
--- parse.y     (revision 16244)
+++ parse.y     (working copy)
@@ -5821,7 +5821,8 @@
                if (!(ruby_scope->flags & SCOPE_CLONE))
                    xfree(ruby_scope->local_tbl);
            }
-           ruby_scope->local_tbl = local_tbl();
+            ruby_scope->local_vars[-1] = 0;
+            ruby_scope->local_tbl = local_tbl();
        }
     }
     local_pop();