This is a multi-part message in MIME format.
--------------020305020404070803010504
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I just synced my machine and got the latest Ruby from the Portage 
repository. Here are the gory details:

 >>> Emerging (3 of 3) dev-lang/ruby-1.8.6_p230 to /
  * ruby-1.8.6-p230.tar.bz2 RMD160 SHA1 SHA256 size ;-) ... 
    [ ok ]
  * checking ebuild checksums ;-) ... 
    [ ok ]
  * checking auxfile checksums ;-) ... 
    [ ok ]
  * checking miscfile checksums ;-) ... 
    [ ok ]
  * checking ruby-1.8.6-p230.tar.bz2 ;-) ... 
    [ ok ]
 >>> Unpacking source...
 >>> Unpacking ruby-1.8.6-p230.tar.bz2 to 
/var/tmp/portage/dev-lang/ruby-1.8.6_p230/work
  * Applying ruby-1.8.6-memory-leak.diff ...
   [ ok ]
  * Applying ruby-1.8.6-revert-r15856.patch ...
   [ ok ]
  * Running eautoreconf in 
'/var/tmp/portage/dev-lang/ruby-1.8.6_p230/work/ruby-1.8.6-p230' ...
  * Running aclocal ...
   [ ok ]
  * Running autoconf ...
   [ ok ]
 >>> Source unpacked.
 >>> Compiling source in 
/var/tmp/portage/dev-lang/ruby-1.8.6_p230/work/ruby-1.8.6-p230 ...

The patches are attached if someone wiser than myself wants to inspect them.

Please file any comments to the Gentoo bug tracker at

https://bugs.gentoo.org/show_bug.cgi?id"5465

I'll probably check openSUSE 11 in a little while ... that's the only 
other distro I have loaded at the moment.

--------------020305020404070803010504
Content-Type: text/plain;
 nameuby-1.8.6-memory-leak.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filenameuby-1.8.6-memory-leak.diff"

Index: ptr.c
--- ptr.c       (revision 12047)
+++ ptr.c       (working copy)
@@ -53,6 +53,8 @@
 void
 dlptr_free(struct ptr_data *data)
 {
+  if (!data)
+    return;
   if (data->ptr) {
     DEBUG_CODE({
       printf("dlptr_free(): removing the pointer `0x%x' from the MemorySpace\n",
@@ -69,4 +71,5 @@
   if (data->stype) dlfree(data->stype);
   if (data->ssize) dlfree(data->ssize);
   if (data->ids) dlfree(data->ids);
+  dlfree(data);
 }

 void
Index: sym.c
--- sym.c       (revision 12047)
+++ sym.c       (working copy)
@@ -57,6 +57,8 @@
 void
 dlsym_free(struct sym_data *data)
 {
+  if(!data)
+    return;
   if( data->name ){
     DEBUG_CODE({
       printf("dlsym_free(): free(data->name:%s)\n",data->name);
@@ -69,4 +71,5 @@
     });
     free(data->type);
   }
+  dlfree(data);
 }

 VALUE
Index: handle.c
--- handle.c    (revision 12047)
+++ handle.c    (working copy)
@@ -10,7 +10,10 @@
 void
 dlhandle_free(struct dl_handle *dlhandle)
 {
+  if (!dlhandle)
+    return;
   if (dlhandle->ptr && dlhandle->open && dlhandle->enable_close) {
-    dlclose(dlhandle->ptr);
+    dlclose(dlhandle->ptr);
   }
+  dlfree(dlhandle);
 }

 VALUE

--------------020305020404070803010504
Content-Type: text/plain;
 nameuby-1.8.6-revert-r15856.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filenameuby-1.8.6-revert-r15856.patch"

$ svn diff -c -15856  http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8

Revert the following commit since it breaks Rails 2.0
------------------------------------------------------------------------
r15856 | matz | 2008-03-30 00:47:54 +0900 (Sun, 30 Mar 2008) | 2 lines
Changed paths:
   M /branches/ruby_1_8/ChangeLog
   M /branches/ruby_1_8/class.c

* class.c (clone_method): should copy cref as well.
  [ruby-core:15833]



$ svn diff -c -15856  http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8

Revert the following commit since it breaks Rails 2.0
------------------------------------------------------------------------
r15856 | matz | 2008-03-30 00:47:54 +0900 (Sun, 30 Mar 2008) | 2 lines
Changed paths:
   M /branches/ruby_1_8/ChangeLog
   M /branches/ruby_1_8/class.c

* class.c (clone_method): should copy cref as well.
  [ruby-core:15833]



Index: ruby-1.8.6-p230/class.c
--- ruby-1.8.6-p230.orig/class.c
+++ ruby-1.8.6-p230/class.c
@@ -48,26 +48,13 @@ rb_class_new(super)
     return rb_class_boot(super);
 }
 
-struct clone_method_data {
-    st_table *tbl;
-    VALUE klass;
-};
-
 static int
-clone_method(mid, body, data)
+clone_method(mid, body, tbl)
     ID mid;
     NODE *body;
-    struct clone_method_data *data;
+    st_table *tbl;
 {
-    NODE *fbody  ody->nd_body;
-
-    if (fbody && nd_type(fbody) NODE_SCOPE) {
-	VALUE cref  ata->klass ?
-	    (VALUE)NEW_NODE(NODE_CREF,data->klass,0,fbody->nd_rval) :
-	    fbody->nd_rval;
-	fbody  EW_NODE(NODE_SCOPE, fbody->nd_tbl, cref, fbody->nd_next);
-    }
-    st_insert(data->tbl, mid, (st_data_t)NEW_METHOD(fbody, body->nd_noex));
+    st_insert(tbl, mid, (st_data_t)NEW_METHOD(body->nd_body, body->nd_noex));
     return ST_CONTINUE;
 }
 
@@ -78,8 +65,7 @@ rb_mod_init_copy(clone, orig)
 {
     rb_obj_init_copy(clone, orig);
     if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) {
-	RBASIC(clone)->klass  BASIC(orig)->klass;
-	RBASIC(clone)->klass  b_singleton_class_clone(clone);
+	RBASIC(clone)->klass  b_singleton_class_clone(orig);
     }
     RCLASS(clone)->super  CLASS(orig)->super;
     if (RCLASS(orig)->iv_tbl) {
@@ -92,12 +78,9 @@ rb_mod_init_copy(clone, orig)
 	st_delete(RCLASS(clone)->iv_tbl, (st_data_t*)&id, 0);
     }
     if (RCLASS(orig)->m_tbl) {
-	struct clone_method_data data;
-
-	data.tbl  CLASS(clone)->m_tbl  t_init_numtable();
-	data.klass  VALUE)clone;
-
-	st_foreach(RCLASS(orig)->m_tbl, clone_method, (st_data_t)&data);
+	RCLASS(clone)->m_tbl  t_init_numtable();
+	st_foreach(RCLASS(orig)->m_tbl, clone_method,
+	  (st_data_t)RCLASS(clone)->m_tbl);
     }
 
     return clone;
@@ -143,22 +126,9 @@ rb_singleton_class_clone(obj)
 	if (RCLASS(klass)->iv_tbl) {
 	    clone->iv_tbl  t_copy(RCLASS(klass)->iv_tbl);
 	}
-	{
-	    struct clone_method_data data;
-
-	    data.tbl  lone->m_tbl  t_init_numtable();
-	    switch (TYPE(obj)) {
-	      case T_CLASS:
-	      case T_MODULE:
-		data.klass  bj;
-		break;
-	      default:
-		data.klass  ;
-		break;
-	    }
-
-	    st_foreach(RCLASS(klass)->m_tbl, clone_method, (st_data_t)&data);
-	}
+	clone->m_tbl  t_init_numtable();
+	st_foreach(RCLASS(klass)->m_tbl, clone_method,
+	  (st_data_t)clone->m_tbl);
 	rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone);
 	FL_SET(clone, FL_SINGLETON);
 	return (VALUE)clone;

--------------020305020404070803010504--