[#25035] 拡張ライブラリへの共有ライブラリのPATHの埋め込み — Takahiro Kambe <taca@...>

こんにちは。

16 messages 2004/12/03
[#25070] Re: 拡張ライブラリへの共有ライブラリのPATHの埋め込み — nobu@... 2004/12/06

なかだです。

[#25071] Re: 拡張ライブラリへの共有ライブラリのPATHの埋め込み — Takahiro Kambe <taca@...> 2004/12/06

In message <200412060607.iB667giF007533@sharui.nakada.niregi.kanuma.tochigi.jp>

[#25089] Re: 拡張ライブラリへの共有ライブラリのPATHの埋め込み — nobu@... 2004/12/07

なかだです。

[#25090] Re: 拡張ライブラリへの共有ライブラリのPATHの埋め込み — Takahiro Kambe <taca@...> 2004/12/07

In message <200412070015.iB70FAiF012770@sharui.nakada.niregi.kanuma.tochigi.jp>

[#25093] Re: 拡張ライブラリへの共有ライブラリのPATHの埋め込み — akira yamada / やまだあきら <akira@...> 2004/12/07

2004-12-07 (火) の 12:27 +0900 に Takahiro Kambe さんは書きました:

[#25041] temporal locking already locked string on simultaneous write — Tanaka Akira <akr@...17n.org>

同じ文字列をほぼ同時に IO に書き込むと、temporal locking already

13 messages 2004/12/04
[#25042] Re: temporal locking already locked string on simultaneous write — Yukihiro Matsumoto <matz@...> 2004/12/04

まつもと ゆきひろです

[#25043] Re: temporal locking already locked string on simultaneous write — Tanaka Akira <akr@...17n.org> 2004/12/04

In article <1102133507.339625.10453.nullmailer@x31.priv.netlab.jp>,

[#25096] double free problem — "Akinori MUSHA" <knu@...>

 ご無沙汰しております。

15 messages 2004/12/07
[#25099] Re: double free problem — Yukihiro Matsumoto <matz@...> 2004/12/07

Hi,

[#25101] non-stdio buffering — Tanaka Akira <akr@...17n.org>

えぇと、今回 1.9 でなにが起きたのかを私が把握している範囲でまとめてお

18 messages 2004/12/07

[#25152] 1.8 reopen problem with duplex popen — Tanaka Akira <akr@...17n.org>

次のように、1.8 で双方向 popen な IO を reopen するとエラーになること

11 messages 2004/12/10

[#25158] core dump on NetBSD 2.0 — Tanaka Akira <akr@...17n.org>

NetBSD 2.0 で次のようにすると core を吐きます。

18 messages 2004/12/11
[#25159] Re: core dump on NetBSD 2.0 — Tanaka Akira <akr@...17n.org> 2004/12/11

In article <87hdmsivva.fsf@serein.a02.aist.go.jp>,

[#25163] Re: core dump on NetBSD 2.0 — Tanaka Akira <akr@...17n.org> 2004/12/12

In article <87ekhwiv7g.fsf@serein.a02.aist.go.jp>,

[#25165] Re: core dump on NetBSD 2.0 — nobu@... 2004/12/13

なかだです。

[#25167] Re: core dump on NetBSD 2.0 — Tanaka Akira <akr@...17n.org> 2004/12/13

In article <200412130040.iBD0e8Qh003275@sharui.nakada.niregi.kanuma.tochigi.jp>,

[#25193] 1.8.2 release schedule — Yukihiro Matsumoto <matz@...>

まつもと ゆきひろです

15 messages 2004/12/14

[#25299] Re: リリース準備 — Yukihiro Matsumoto <matz@...>

まつもと ゆきひろです

20 messages 2004/12/24
[#25301] Re: リリース準備 — TAKAHASHI Masayoshi <maki@...> 2004/12/24

高橋征義です。

[#25302] test_readline.rb blocks on BSD again — GOTOU Yuuzou <gotoyuzo@...>

In message <20041223175402.3116FC6718@lithium.ruby-lang.org>,

15 messages 2004/12/24
[#25314] Re: test_readline.rb blocks on BSD again — GOTOU Yuuzou <gotoyuzo@...> 2004/12/24

In message <20041224.131211.846943951.gotoyuzo@sawara.does.notwork.org>,

[#25315] Re: test_readline.rb blocks on BSD again — Yukihiro Matsumoto <matz@...> 2004/12/24

まつもと ゆきひろです

[#25317] Re: test_readline.rb blocks on BSD again — WATANABE Hirofumi <eban@...> 2004/12/25

わたなべです。

[ruby-dev:25318] Re: Zlib memory leak ([ruby-list:39235])

From: nobu@...
Date: 2004-12-25 05:29:50 UTC
List: ruby-dev #25318
なかだです。

At Fri, 24 Dec 2004 21:34:27 +0900,
sheepman wrote in [ruby-dev:25309]:
> [ruby-list:39235] で報告した Zlib のメモリリークに対するパッチを書いてみました。

見落としてました。

こういう場合、GCに任せるよりもその場で解放してしまったほうがい
いような気もします。


* ext/zlib/zlib.c (rb_deflate_s_deflate, rb_inflate_s_inflate): ensure
  freeing internal zstreams.  fixed: [ruby-dev:25309]

* ext/zlib/zlib.c (rb_deflate_init_copy): replace rb_deflate_clone.


Index: ext/zlib/zlib.c
===================================================================
RCS file: /cvs/ruby/src/ruby/ext/zlib/zlib.c,v
retrieving revision 1.24
diff -U2 -p -r1.24 zlib.c
--- ext/zlib/zlib.c	18 Dec 2004 07:36:33 -0000	1.24
+++ ext/zlib/zlib.c	25 Dec 2004 05:20:59 -0000
@@ -56,5 +56,5 @@ static void zstream_passthrough_input _(
 static VALUE zstream_detach_input _((struct zstream*));
 static void zstream_reset _((struct zstream*));
-static void zstream_end _((struct zstream*));
+static VALUE zstream_end _((struct zstream*));
 static void zstream_run _((struct zstream*, Bytef*, uInt, int));
 static VALUE zstream_sync _((struct zstream*, Bytef*, uInt));
@@ -81,5 +81,6 @@ static VALUE rb_zstream_closed_p _((VALU
 static VALUE rb_deflate_s_allocate _((VALUE));
 static VALUE rb_deflate_initialize _((int, VALUE*, VALUE));
-static VALUE rb_deflate_clone _((VALUE));
+static VALUE rb_deflate_init_copy _((VALUE, VALUE));
+static VALUE deflate_run _((VALUE));
 static VALUE rb_deflate_s_deflate _((int, VALUE*, VALUE));
 static void do_deflate _((struct zstream*, VALUE, int));
@@ -90,4 +91,5 @@ static VALUE rb_deflate_params _((VALUE,
 static VALUE rb_deflate_set_dictionary _((VALUE, VALUE));
 
+static VALUE inflate_run _((VALUE));
 static VALUE rb_inflate_s_allocate _((VALUE));
 static VALUE rb_inflate_initialize _((int, VALUE*, VALUE));
@@ -671,5 +673,5 @@ zstream_reset(z)
 }
 
-static void
+static VALUE
 zstream_end(z)
     struct zstream *z;
@@ -696,4 +698,5 @@ zstream_end(z)
     }
     z->flags = 0;
+    return Qnil;
 }
 
@@ -1156,24 +1159,29 @@ rb_deflate_initialize(argc, argv, obj)
  */
 static VALUE
-rb_deflate_clone(obj)
-    VALUE obj;
+rb_deflate_init_copy(self, orig)
+    VALUE self, orig;
 {
-    struct zstream *z = get_zstream(obj);
-    struct zstream *z2;
-    VALUE clone;
+    struct zstream *z1 = get_zstream(self);
+    struct zstream *z2 = get_zstream(orig);
     int err;
 
-    clone = zstream_deflate_new(rb_class_of(obj));
-    Data_Get_Struct(clone, struct zstream, z2);
-
-    err = deflateCopy(&z2->stream, &z->stream);
+    err = deflateCopy(&z1->stream, &z2->stream);
     if (err != Z_OK) {
 	raise_zlib_error(err, 0);
     }
+    z1->flags = z2->flags;
 
-    z2->flags = z->flags;
-    CLONESETUP(clone, obj);
-    OBJ_INFECT(clone, obj);
-    return clone;
+    return self;
+}
+
+static VALUE
+deflate_run(args)
+    VALUE args;
+{
+    struct zstream *z = (struct zstream *)((VALUE *)args)[0];
+    VALUE src = ((VALUE *)args)[1];
+
+    zstream_run(z, RSTRING(src)->ptr, RSTRING(src)->len, Z_FINISH);
+    return zstream_detach_buffer(z);
 }
 
@@ -1205,5 +1213,5 @@ rb_deflate_s_deflate(argc, argv, klass)
 {
     struct zstream z;
-    VALUE src, level, dst;
+    VALUE src, level, dst, args[2];
     int err, lev;
 
@@ -1219,7 +1227,7 @@ rb_deflate_s_deflate(argc, argv, klass)
     ZSTREAM_READY(&z);
 
-    zstream_run(&z, RSTRING(src)->ptr, RSTRING(src)->len, Z_FINISH);
-    dst = zstream_detach_buffer(&z);
-    zstream_end(&z);
+    args[0] = (VALUE)&z;
+    args[1] = src;
+    dst = rb_ensure(deflate_run, (VALUE)args, zstream_end, (VALUE)&z);
 
     OBJ_INFECT(dst, src);
@@ -1434,4 +1442,16 @@ rb_inflate_initialize(argc, argv, obj)
 }
 
+static VALUE
+inflate_run(args)
+    VALUE args;
+{
+    struct zstream *z = (struct zstream *)((VALUE *)args)[0];
+    VALUE src = ((VALUE *)args)[1];
+
+    zstream_run(z, RSTRING(src)->ptr, RSTRING(src)->len, Z_SYNC_FLUSH);
+    zstream_run(z, "", 0, Z_FINISH);  /* for checking errors */
+    return zstream_detach_buffer(z);
+}
+
 /*
  * call-seq: Zlib::Inflate.inflate(string)
@@ -1456,5 +1476,5 @@ rb_inflate_s_inflate(obj, src)
 {
     struct zstream z;
-    VALUE dst;
+    VALUE dst, args[2];
     int err;
 
@@ -1467,8 +1487,7 @@ rb_inflate_s_inflate(obj, src)
     ZSTREAM_READY(&z);
 
-    zstream_run(&z, RSTRING(src)->ptr, RSTRING(src)->len, Z_SYNC_FLUSH);
-    zstream_run(&z, "", 0, Z_FINISH);  /* for checking errors */
-    dst = zstream_detach_buffer(&z);
-    zstream_end(&z);
+    args[0] = (VALUE)&z;
+    args[1] = src;
+    dst = rb_ensure(inflate_run, (VALUE)args, zstream_end, (VALUE)&z);
 
     OBJ_INFECT(dst, src);
@@ -3439,5 +3458,5 @@ void Init_zlib()
     rb_define_alloc_func(cDeflate, rb_deflate_s_allocate);
     rb_define_method(cDeflate, "initialize", rb_deflate_initialize, -1);
-    rb_define_method(cDeflate, "clone", rb_deflate_clone, 0);
+    rb_define_method(cDeflate, "initialize_copy", rb_deflate_init_copy, 0);
     rb_define_method(cDeflate, "deflate", rb_deflate_deflate, -1);
     rb_define_method(cDeflate, "<<", rb_deflate_addstr, 1);


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦

In This Thread