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

e$B0J2<$N%W%m%0%i%`$G!"e(B
wrong argument type #Class:0x825d23c (expected Data) (TypeError)
e$B$H$$$&4qL/$J%(%i!<$,=P$^$9!#e(B

% ./ruby -ve ‘f = open("/tmp/x", “w”)
1000.times { f.dup.print “a” }
GC.start

ruby 1.9.1 (2008-12-24 patchlevel-5000 trunk 20956) [i686-linux]
-e:2:in initialize_copy': wrong argument type #<Class:0x825d23c> (expected Data) (TypeError) from -e:2:indup’
from -e:2:in block in <main>' from -e:2:intimes’
from -e:2:in `’

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

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 A. <[email protected]> writes: | |e$B0J2<$N%W%m%0%i%$G!“e(B
| wrong argument type #Class:0x825d23c (expected Data) (TypeError)
|e$B$H$$$&4qL/$J%(%i!<$,=P$^$9!#e(B
|
|% ./ruby -ve 'f = open(”/tmp/x”, “w”)
|1000.times { f.dup.print “a” }
|GC.start
|’

IOe$B$N%U%!%$%J%i%$%6$r<B9T$9$k;~E@$G$Oe(Bwrite_locke$B$,$9$G$K2rJ|$5e(B
e$B$l$A$c$C$F$k$+$i$N$h$&$G$9!#$H$j$"$($:!"e(B

  • e$B%U%!%$%J%i%$%6<B9TA0$Ke(Bwrite_locke$B$r%/%j%"e(B
  • io_fflushe$B$Ge(Bwrite_locke$B$rLdEzL5MQ$G;2>H$7$F$$$?$N$r$d$a$ke(B

e$B$H$$$&BP1~$G>e5-$N%W%m%0%i%`$OF0$$$F$$$k$h$&$K8+$($^$9!#$,!"e(B
e$B$o$6$o$6e(Bwrite_locke$B$r$+$1$F$$$?$N$r$O$:$7$A$c$C$FNI$$$N$+$H$$e(B
e$B$&H=CG$O;d$K$O$D$-$+$M$^$9!#e(B

e$B%Q%C%A$rE:IU$7$^$9!#e(B

— 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) {

e$B$J$+$@$G$9!#e(B

At Wed, 24 Dec 2008 10:08:22 +0900,
Yukihiro M. wrote in [ruby-dev:37573]:

IOe$B$N%U%!%$%J%i%$%6$r<B9T$9$k;~E@$G$Oe(Bwrite_locke$B$,$9$G$K2rJ|$5e(B
e$B$l$A$c$C$F$k$+$i$N$h$&$G$9!#$H$j$"$($:!"e(B

  • e$B%U%!%$%J%i%$%6<B9TA0$Ke(Bwrite_locke$B$r%/%j%"e(B
  • io_fflushe$B$Ge(Bwrite_locke$B$rLdEzL5MQ$G;2>H$7$F$$$?$N$r$d$a$ke(B

e$B$H$$$&BP1~$G>e5-$N%W%m%0%i%`$OF0$$$F$$$k$h$&$K8+$($^$9!#$,!"e(B
e$B$o$6$o$6e(Bwrite_locke$B$r$+$1$F$$$?$N$r$O$:$7$A$c$C$FNI$$$N$+$H$$e(B
e$B$&H=CG$O;d$K$O$D$-$+$M$^$9!#e(B

e$B%U%!%$%J%i%$%6<B9T;~$O6%9g$9$k%9%l%C%I$O$J$$$O$:$H;W$o$l$k$N$G!"e(B
e$B$O$:$7$A$c$C$F$h$$$s$G$O$J$$$G$7$g$&$+!#e(B

e$B$J$+$@$G$9!#e(B

At Wed, 24 Dec 2008 20:30:21 +0900,
Yukihiro M. wrote in [ruby-dev:37581]:

|> e$B$o$6$o$6e(Bwrite_locke$B$r$+$1$F$$$?$N$r$O$:$7$A$c$C$FNI$$$N$+$H$$e(B
|> e$B$&H=CG$O;d$K$O$D$-$+$M$^$9!#e(B
|
|e$B%U%!%$%J%i%$%6<B9T;~$O6%9g$9$k%9%l%C%I$O$J$$$O$:$H;W$o$l$k$N$G!"e(B
|e$B$O$:$7$A$c$C$F$h$$$s$G$O$J$$$G$7$g$&$+!#e(B

e$B$s$8$c!"%3%_%C%H$7$^$9!#$H$3$m$G!“e(BGILe$B$,$”$k0J>e!“e(Bmutexe$B$r;H$oe(B
e$B$J$/$F$bC1=c$J%U%i%0$G%m%C%/$,<B8=$G$-$=$&$J5$$,$9$k$s$G$9$,!#e(B
e$B$=$&$9$k$H$$$m$$$m%3%9%H$,0B$=$&$G$9$,!”$=$&$G$b$J$$$s$G$9$+e(B
e$B$M!#e(B

e$B=q$-9~$_$,e(Bblocking
regione$B$GJB9TF0:n$9$k$N$G!“DL>o$Ne(Bflushe$B$G$Oe(B
mutexe$B$,I,MW$G$9!#%U%!%$%J%i%$%6$,Av$k;~E@$G$O!”$=$&$$$&%9%l%C%Ie(B
e$B$O=*N;$7$F$$$k$O$:e(B(e$B$@$+$i2rJ|$G$-$ke(B)e$B$@$H;W$$$^$9!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:37574] Re: [Bug:1.9] `initialize_copy’: wrong
argument type #Class:0x825d23c (expected Data) (TypeError)”
on Wed, 24 Dec 2008 11:31:05 +0900, Nobuyoshi N.
[email protected] writes:

|> e$B$o$6$o$6e(Bwrite_locke$B$r$+$1$F$$$?$N$r$O$:$7$A$c$C$FNI$$$N$+$H$$e(B
|> e$B$&H=CG$O;d$K$O$D$-$+$M$^$9!#e(B
|
|e$B%U%!%$%J%i%$%6<B9T;~$O6%9g$9$k%9%l%C%I$O$J$$$O$:$H;W$o$l$k$N$G!"e(B
|e$B$O$:$7$A$c$C$F$h$$$s$G$O$J$$$G$7$g$&$+!#e(B

e$B$s$8$c!"%3%_%C%H$7$^$9!#$H$3$m$G!“e(BGILe$B$,$”$k0J>e!“e(Bmutexe$B$r;H$oe(B
e$B$J$/$F$bC1=c$J%U%i%0$G%m%C%/$,<B8=$G$-$=$&$J5$$,$9$k$s$G$9$,!#e(B
e$B$=$&$9$k$H$$$m$$$m%3%9%H$,0B$=$&$G$9$,!”$=$&$G$b$J$$$s$G$9$+e(B
e$B$M!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:37589] Re: [Bug:1.9] `initialize_copy’: wrong
argument type #Class:0x825d23c (expected Data) (TypeError)”
on Thu, 25 Dec 2008 04:46:23 +0900, Nobuyoshi N.
[email protected] writes:

|e$B=q$-9~$_$,e(Bblocking regione$B$GJB9TF0:n$9$k$N$G!“DL>o$Ne(Bflushe$B$G$Oe(B
|mutexe$B$,I,MW$G$9!#%U%!%$%J%i%$%6$,Av$k;~E@$G$O!”$=$&$$$&%9%l%C%Ie(B
|e$B$O=*N;$7$F$$$k$O$:e(B(e$B$@$+$i2rJ|$G$-$ke(B)e$B$@$H;W$$$^$9!#e(B

e$B$=$&$$$($P$=$&$$$&OC$G$7$?$M!#$9$C$+$jK:$l$F$^$7$?!#e(B

e$B%A%1%C%He(B #923 e$B$,99?7$5$l$^$7$?!#e(B (by Yuki S.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B

applied in r21039

http://redmine.ruby-lang.org/issues/show/923