[#37248] [Feature:1.9] Enumerator#inspect — "Yusuke ENDOH" <mame@...>

遠藤です。

12 messages 2008/12/02

[#37337] [Feature #841] Object#self — "rubikitch ." <redmine@...>

Feature #841: Object#self

13 messages 2008/12/09

[#37513] Current status of 1.9.1 RC1's issues — "Yugui (Yuki Sonoda)" <yugui@...>

Hi, folks

14 messages 2008/12/20
[#37516] Re: Current status of 1.9.1 RC1's issues — Masatoshi SEKI <m_seki@...> 2008/12/20

咳といいます。

[#37576] [BUG:trunk] encoding for stdio's — "Yugui (Yuki Sonoda)" <yugui@...>

Yuguiです。

11 messages 2008/12/24

[ruby-dev:37573] Re: [Bug:1.9] `initialize_copy': wrong argument type #<Class:0x825d23c> (expected Data) (TypeError)

From: Yukihiro Matsumoto <matz@...>
Date: 2008-12-24 01:08:22 UTC
List: ruby-dev #37573
まつもと ゆきひろです

In message "Re: [ruby-dev:37572] [Bug:1.9] `initialize_copy': wrong argument type #<Class:0x825d23c> (expected Data) (TypeError)"
    on Wed, 24 Dec 2008 01:44:13 +0900, Tanaka Akira <akr@fsij.org> writes:
|
|以下のプログラムで、
|  wrong argument type #<Class:0x825d23c> (expected Data) (TypeError)
|という奇妙なエラーが出ます。
|
|% ./ruby -ve 'f = open("/tmp/x", "w")
|1000.times { f.dup.print "a" }
|GC.start
|'

IOのファイナライザを実行する時点ではwrite_lockがすでに解放さ
れちゃってるからのようです。とりあえず、

  * ファイナライザ実行前にwrite_lockをクリア
  * io_fflushでwrite_lockを問答無用で参照していたのをやめる

という対応で上記のプログラムは動いているように見えます。が、
わざわざwrite_lockをかけていたのをはずしちゃって良いのかとい
う判断は私にはつきかねます。

パッチを添付します。

--- a/io.c
+++ b/io.c
@@ -558,7 +558,13 @@ io_fflush(rb_io_t *fptr)
   retry:
     if (fptr->wbuf_len == 0)
         return 0;
-    r = rb_mutex_synchronize(fptr->write_lock, io_flush_buffer, (VALUE)fptr);
+    if (fptr->write_lock) {
+	r = rb_mutex_synchronize(fptr->write_lock, io_flush_buffer, (VALUE)fptr);
+    }
+    else {
+	long l = io_writable_length(fptr, fptr->wbuf_len);
+	r = rb_write_internal(fptr->fd, fptr->wbuf+fptr->wbuf_off, l);
+    }
     /* xxx: Other threads may modify wbuf.
      * A lock is required, definitely. */
     rb_io_check_closed(fptr);
@@ -3194,6 +3200,7 @@ rb_io_fptr_finalize(rb_io_t *fptr)
 {
     if (!fptr) return 0;
     fptr->pathv = Qnil;
+    fptr->write_lock = 0;
     if (0 <= fptr->fd)
 	rb_io_fptr_cleanup(fptr, Qtrue);
     if (fptr->rbuf) {

In This Thread