[Bug #2575] a test fail for IO#readpartial is broken on *BSD

Bug #2575: a test fail for IO#readpartial is broken on *BSD
http://redmine.ruby-lang.org/issues/show/2575

e$B5/I<<Te(B: Takahiro K.
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
e$B%+%F%4%je(B: core
ruby -v: ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-netbsdelf]

IO#readpartiale$B$N%F%9%H$K<:GT$7$^$9!#3NG’$Oe(BNetBSD 5.0_STABLE,
current (5.99.22)e$B$He(BFreeBSD
7.2-STABLEe$B!"$$$:$l$be(Bi386e$B4D6-$G9T$$$^$7$?!#e(B

test/ruby/test_io.rb e$B$Ne(B test_readpartial_pos() e$B$K!"e(B

  open("foo", "w") {|f| f << "abc" }
  open("foo") {|f|
    f.seek(0)
    assert_equal("ab", f.readpartial(2))
    assert_equal(2, f.pos)
  }

e$B$H$$$C$?%F%9%H$,$"$j$^$9!#$3$3$G!“e(Bf.pose$B$N7k2L$,%<%m$H$J$C$F%F%9%H$K<:GT$7$^$9!#D>A0$Ne(Bf.seek(0)e$B$r:o=|$9$k$H%F%9%[email protected]$9$k$h$&$K$J$j$^$9$,!”$3$NM-L5$G7k2L$,JQ$o$C$F$O$J$j$^$;$s!#e(B

io.ce$B$Ne(Bio_getpartial()e$B$G$O!"e(B

read_buffered_data()e$B$Ge(BFILEe$B9=B$BN$KFI$9~$:Q$$N%G!<%?$rFI$s$G$$k!#e(B
2. e$BFI$9~$:Q$_$N%G!<%?$,$J$1$l$P!"e(B
2.1 read(2)e$B$G%G!<%?$re(BFILEe$B9=B$BN$KFI$_9~$`!#e(B
2.2
e$B8e$Ge(Bfflush(3)e$B$r8F$S=P$7$Fe([email protected]@-$,<h$le(B(e$B$k$3$H$re(B
e$B4|BT$7$F$$e(B)e$B$k!#e(B

e$B$H$$$C$?$3$H$r$7$F$$$^$9!#e(B2.1e$B$N=hM}$O!"e(B

merge revision(s) 21913:
* io.c (io_getpartial): fflush after read for updating pos in
FILE.
not portable, I guess. [ruby-core:21561]

e$B$H%3%_%C%H$5$l$F$$$^$9!#$3$3$G?dB,$5$l$F$$$k$h$&$K<B:]$K0?"@-$O$"$j$^$;$s!#$=$b$=$b!“e(Bfflush(3)e$B$G9=B$BN$NFbMF$,E,@Z$K$J$5$l$k$H4|BT$9$k$3$H$KL5M}$,$”$k5$$b$7$^$9!#e(B

*BSDe$B$Ne(BFILEe$B9=B$BNe(B([email protected](B)e$B$K$O!"e(B

o e$B%U%!%$%kCf$N%*%U%;%C%H$r<($99=B$BN%a%s%Pe(B _offset
e$B$,$"$j$^$9!#e(B
o
e$B9=B$BN%a%s%Pe(B_flagse$B$N%U%i%C%0CM$K$O!“e(B_offsete$B$NCM$,<B:]$KM-8z$+$I$&$+$re(B
e$B<($9e(B __SOFF e$B$H$$$&CM$,$”$j$^$9!#e(B

e$B$=$7$F!"$3$NLdBj$O0J2<$N$h$&[email protected]@$G$-$^$9!#e(B

(1)
f.seek(0)e$B$r8F$S=P$9$He(Bfseeko(3)e$B$,8F$S=P$5$l$F!"e(B_offsete$B$KCM$He(B__SOFFe$B$,e(B
e$B%U%i%C%0$,@_Dj$5$l$^$9!#$3$N$H$-$Ne(B _offset
e$B$,8e$Ne(Bf.telle$B$NLa$jCM$H$J$Ce(B
e$B$F$$$^$9!#e(B

(2)
f.seek(0)e$B$r8F$S=P$5$J$$$H!"e(Bf.telle$B$N8F$S=P$5$l$?;[email protected]$Ge(B_offsete$B$KCM$He(B
__SOFFe$B$,@_Dj$5$l$k$?$a!"4|BT$7$?CM$,JV$k$3$H$K$J$j$^$9!#e(B

e$B2r7h:v$H$7$F$O!“e(Bfflush(3)e$B$N8F$S=P$7$KBe$($Fe(B__SOFFe$B$r%”%s%;%C%H$7$F$+$ie(Bftello(3)e$B$r8F$S=P$9$H$$$C$?$3$H$,9M$($i$l$^$9!#<h$j4:$($:$N%Q%C%A$G!"LdBj$,2r7h$9$k$3$H$r3NG’$7$^$7$?!#e(B

In message [email protected]
on Fri, 8 Jan 2010 12:40:04 +0900,
Takahiro K. [email protected] wrote:

e$B2r7h:v$H$7$F$O!“e(Bfflush(3)e$B$N8F$S=P$7$KBe$($Fe(B__SOFFe$B$r%”%s%;%C%H$7$F$+$ie(B
ftello(3)e$B$r8F$S=P$9$H$$$C$?$3$H$,9M$($i$l$^$9!#<h$j4:$($:$N%Q%C%A$G!"e(B
e$BLdBj$,2r7h$9$k$3$H$r3NG’$7$^$7$?!#e(B
e$B$3$NLdBj$O2r7h$7$^$9$,!"2r7h$7$F$$$k$N$O%*%U%;%C%[email protected]$1$G!"e(B
read_buffered_data()e$BJU$j$K$Oe(Bfread(3)e$B8F$S=P$7$F$k%3!<%I$be(B
e$BB8:_$7$^$9!#e(B

e$BI{:nMQ$b$"$k$G$7$g$&$7!":G=E$K$Oe(BRuby
1.9e$B$Ge(Bstdioe$B<N$F$k$He(B
e$B$$$&OC$K7k$SIU$/$N$G$7$g$&!#e(B

2010e$BG/e(B1e$B7ne(B8e$BF|e(B14:02 Takahiro K.
[email protected]:

e$BI{:nMQ$b$"$k$G$7$g$&$7!":G=E$K$Oe(BRuby 1.9e$B$Ge(Bstdioe$B<N$F$k$He(B
e$B$$$&OC$K7k$SIU$/$N$G$7$g$&!#e(B

e$B$($’!"e(B1.9 e$B$G$O2r7h$7$F$$$F!"e(Bstdio
e$B$r;H$&[email protected]$7$$2r7h$OL5M}$J$N$G!"e(B
1.8 e$B$G$O!"J]<i2DG=$JHO0O$G:Y9)$9$k$H$$$&46$8$G$9$+$M!#e(B

e$B%A%1%C%He(B #2575 e$B$,99?7$5$l$^$7$?!#e(B (by Takahiro K.)

[ruby-dev:40051]
e$B$KE:IU$N%Q%C%A$G8=>]$,2r7h$9$k$3$H$r3NG’$7$^$7$?!#e(B
e$B:,K\E*$J860x$O!"e(BBug
#1872e$B$G!"e(Btimere$B%9%l%C%I4X78$+2?$+$N4X78$G82:_2=$7$?$H9M$($i$l$^$9!#e(B


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

In message [email protected]
on Tue, 12 Jan 2010 15:18:06 +0900,
Takahiro K. [email protected] wrote:

[ruby-dev:40051] e$B$KE:IU$N%Q%C%A$G8=>]$,2r7h$9$k$3$H$r3NG’$7$^$7$?!#e(B
e$B$H!"=q$-$^$7$?$,!"e(B

e$B:,K\E*$J860x$O!"e(BBug #1872e$B$G!“e(Btimere$B%9%l%C%I4X78$+2?$+$N4X78$G82:_2=$7e(B
e$B$?$H9M$($i$l$^$9!#e(B
e$BC1=c$J%P%C%/%/%)!<%H$de(Bsystem()e$B$N<B9T$G$NLdBj$O2r>C$7$^$7$?$,!”$d$O$j!"e(B

test_local_barrier(TC_Thread):

e$B$G;I$5$k$H$-$,$"$k$h$&$G$9!#e(B


e$B?@8Me(B e$BN4Gne(B(e$B$+$s$Ye(B e$B$?$+$R$me(B) at e$B;E;v>le(B

P.S.
e$B;I$5$C$?%W%m%;%9$re(B kill -KILL e$B$G=N;$5$;$F!"e(Bmake test-all
e$B$r=
$o$i$;$?e(B
e$B$"$H$K!"?F$J$7$H$J$C$?e(Brubye$B$N%W%m%;%9$,e(B10e$B8D$/$i$$;D$j!“e(Bparkede$B$J>uBVe(B
(pthread_joine$B$+2?$+e(B)e$B$H$J$C$F$^$9!#e(BNetBSD current
(5.99.22)e$B<+BN$b2x$7$$e(B
e$B$H$3$m$O$”$k$N$G!"<h$j4:$($:e(B 5.99.23
e$B$K$7$F$+$i:F3NG’$9$kM=Dj$G$9!#e(B

e$B%A%1%C%He(B #2575 e$B$,99?7$5$l$^$7$?!#e(B (by Takahiro K.)

e$B?=$7Lu$"$j$^$;$s$,!"e(Bredminee$B$KEPO?$5$l$?!"e(B

[ruby-dev:40055]e$B$K$h$k%3%a%s%He(B#2
[ruby-dev:40056]e$B$K$h$k%3%a%s%He(B#3)

e$B$K$D$$$F$O!"e(BIO#readpartiale$B$NLdBj$H$OL54X78$G$7$?!#e(B


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

e$B%A%1%C%He(B #2575 e$B$,99?7$5$l$^$7$?!#e(B (by Takahiro K.)

e$B%U%!%$%ke(B io.c.diff e$BDI2Ce(B

Hi John.

Dose your patch solve the partial read problem on FreeBSD without
io.c.diff,
or your patch provide additional fix?

Anyway, I rewrite slightly your patch and merged my updated fix to
attached file.

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

e$B%A%1%C%He(B #2575 e$B$,99?7$5$l$^$7$?!#e(B (by John Bader)

I have issues with that on FreeBSD. I ran unicorn and it delivered only
partial responses. The maintainer fixed this with:

diff --git a/io.c b/io.c
index 375cbc8…d4d28e5 100644
— a/io.c
+++ b/io.c
@@ -122,6 +122,9 @@ extern void Init_File _((void));

endif

#endif

+#define preserving_errno(stmts) \

  • do {int saved_errno = errno; stmts; errno = saved_errno;} while (0)

VALUE rb_cIO;
VALUE rb_eEOFError;
VALUE rb_eIOError;
@@ -490,7 +493,7 @@ io_fwrite(str, fptr)
r = write(fileno(f), RSTRING(str)->ptr+offset, l);
TRAP_END;
#if BSD_STDIO

  • fseeko(f, lseek(fileno(f), (off_t)0, SEEK_CUR), SEEK_SET);
  • preserving_errno(fseeko(f, lseek(fileno(f), (off_t)0, SEEK_CUR),
    SEEK_SET));
    #endif
    if (r == n) return len;
    if (0 <= r) {

This resolved the issue for me. I applied the patch to the FreeBSD
ruby18 port and reinstalled.

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs