From: Sylvain Joyeux Date: 2007-09-14T16:59:55+09:00 Subject: Re: Next 1.8.6 on Sept. 22 --Boundary-00=_y9j6GR7jdoyrFdt Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Sunday 09 September 2007 20:57:32 Urabe Shyouhei wrote: > Sylvain Joyeux wrote: > > [ext/dl] fix free-function for DLPtrData objects: should not > > re-allocate > > I see no serious problem on your patch. I've forwarded your post to > the ext/dl maintainer and it's up to him whether the patch is applied. Well .. I don't care if you apply this particular patch. But note the following: 1/ if you add the rb_bug in garbage_collect, DL will not be useable anymore 2/ if you *don't* add the rb_bug, then anyone using DL may have ruby crash anytime. That's one of the problems I have with the Ruby development process. You don't seem to care about the interpreter crashing or not being functional (see how 1.8.6 threading support is broken for more than 6 months). Anyway. Here are two new patches related to ruby/dl. 0001-dl-fix-memory-leak-introduced-in-correction-of-the.patch fixes a memory leak issue for my previous patch (so, it should be applied if the patch is applied). 0002-dl-do-not-override-free-functions-of-already-defin.patch behaviour fix and may not be applied. It can just cause random crashes if someone uses DL in its extensions without a deep knowledge of DL implementation. commit ff65bd4dfcd3a5d329762176c4b81f029c9e7b6a Author: doudou Date: Thu Sep 13 17:30:22 2007 +0200 [dl] do not override free functions of already defined DLPtr. Instead, raise an error commit fec797f159ae03a4453f248115e4a8f77d1f8f34 Author: doudou Date: Wed Sep 12 14:45:24 2007 +0200 [dl] fix memory leak introduced in correction of the GC bug The fix for the GC bug in DL has introduced a memory leak (we were keeping all DLPtr objects from garbage collection). This patch fixes that. Sylvain --Boundary-00=_y9j6GR7jdoyrFdt Content-Type: text/x-diff; charset="iso-2022-jp"; name="0001-dl-fix-memory-leak-introduced-in-correction-of-the.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-dl-fix-memory-leak-introduced-in-correction-of-the.patch" =46rom fec797f159ae03a4453f248115e4a8f77d1f8f34 Mon Sep 17 00:00:00 2001 =46rom: doudou Date: Wed, 12 Sep 2007 14:45:24 +0200 Subject: [PATCH] [dl] fix memory leak introduced in correction of the GC bug The fix for the GC bug in DL has introduced a memory leak (we were keeping all DLPtr objects from garbage collection). This patch fixes that. =2D-- ext/dl/ptr.c | 12 +----------- 1 files changed, 1 insertions(+), 11 deletions(-) diff --git a/ext/dl/ptr.c b/ext/dl/ptr.c index dac1397..7ca41f7 100644 =2D-- a/ext/dl/ptr.c +++ b/ext/dl/ptr.c @@ -33,16 +33,6 @@ static struct st_hash_type memory_table_type =3D { }; static st_table* DLMemoryTable; =20 =2Dstatic int =2Dmemory_table_mark_i(void* key, VALUE value, void* arg) =2D{ =2D rb_gc_mark(value); =2D return ST_CONTINUE; =2D} =2Dstatic void memory_table_mark(VALUE table) { =2D st_foreach(DLMemoryTable, memory_table_mark_i, 0); =2D} =2D static void memory_table_free(VALUE table) { //st_free_table(DLMemoryTable); } @@ -1101,7 +1091,7 @@ Init_dlptr() =20 rb_mDLMemorySpace =3D rb_define_module_under(rb_mDL, "MemorySpace"); DLMemoryTable =3D st_init_table(&memory_table_type); =2D rb_DLMemoryTable =3D Data_Wrap_Struct(rb_cObject, memory_table_mark, m= emory_table_free, DLMemoryTable); + rb_DLMemoryTable =3D Data_Wrap_Struct(rb_cObject, NULL, memory_table_fre= e, DLMemoryTable); rb_define_const(rb_mDLMemorySpace, "MemoryTable", rb_DLMemoryTable); rb_define_module_function(rb_mDLMemorySpace, "each", rb_dlmem_each, 0); } =2D-=20 1.5.3.1 --Boundary-00=_y9j6GR7jdoyrFdt Content-Type: text/x-diff; charset="iso-2022-jp"; name="0002-dl-do-not-override-free-functions-of-already-defin.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0002-dl-do-not-override-free-functions-of-already-defin.patch" =46rom ff65bd4dfcd3a5d329762176c4b81f029c9e7b6a Mon Sep 17 00:00:00 2001 =46rom: doudou Date: Thu, 13 Sep 2007 17:30:22 +0200 Subject: [PATCH] [dl] do not override free functions of already defined DLP= tr. Instead, raise an error =2D-- ext/dl/ptr.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/ext/dl/ptr.c b/ext/dl/ptr.c index 7ca41f7..cf0369e 100644 =2D-- a/ext/dl/ptr.c +++ b/ext/dl/ptr.c @@ -140,7 +140,8 @@ rb_dlptr_new2(VALUE klass, void *ptr, long size, freefu= nc_t func) else{ if (func) { Data_Get_Struct(val, struct ptr_data, data); =2D data->free =3D func; + if (data->free !=3D func) + rb_raise(rb_eArgError, "cannot override the free function of an alrea= dy referenced memory zone"); } } } =2D-=20 1.5.3.1 --Boundary-00=_y9j6GR7jdoyrFdt--