[Bug #1848] Net::SSH hangs

Bug #1848: Net::SSH hangs
http://redmine.ruby-lang.org/issues/show/1848

e$B5/I<<Te(B: Shyouhei U.
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
e$B%+%F%4%je(B: core, Target version: Ruby 1.8.7
ruby -v: 1.8.7-p135 and later

Revision r21165
e$B0J9_!“e(BNet::SSHe$B$r;H$&>l9ge(B(e$B6qBNE*$K$$$&$He(BCapistrano)e$B$G!”%9%l%C%[email protected]$jBX$($,$&$^$/$$$+$J$$$H$$$&Js9p$r<u$1$^$7$?e(B

e$B$^$?J9$-$G$b$&$7$o$1$J$$e(B

https://capistrano.lighthouseapp.com/projects/8716/tickets/79
e$B$3$N$X$s$,4X78$7$F$$$k$+$b!#$7$F$J$$$+$b!#e(B

e$B:F8=J}K!e(B

[“localhost”,“localhost”].map {|h| Thread.new{Net::SSH.start(h,
“foo”)}}.each {|t| t.join}

proposed patch against 1.8.7

— eval.c (revision 24335)
+++ eval.c (working copy)
@@ -11228,7 +11228,7 @@
break;
}
if ((th->status == THREAD_RUNNABLE || th == th_found) &&
th->stk_ptr) {

  •       if (!next || next->priority < th->priority) {
    
  •       if (!next || next->priority <= th->priority) {
                   th_found->status = THREAD_RUNNABLE;
                   th_found->wait_for = 0;

Tietew e$B$G$9!#e(B

e$B$3$l!“F1$82U=j$G;I$5$C$F:$$C$F$$$?$N$G$9$,!”$3$N%Q%C%A$G2r7h$7$^$7$?!#e(B
ruby_1_8e$B%V%i%s%A$G$9!#e(Bruby_1_8_7e$B%V%i%s%A$OL$3NG’!#e(B

$ cap deploy

  • executing `deploy’
  • executing “"
    servers: ["server1.
    ”, “server2.*****”]
    (e$B$3$3$G;I$5$ke(B)

On Fri, 31 Jul 2009 16:00:27 +0900
In article [email protected]
[[ruby-dev:38971] [Bug #1848] Net::SSH hangs]

e$B%A%1%C%He(B #1848 e$B$,99?7$5$l$^$7$?!#e(B (by Shyouhei U.)

e$B%Q%C%A$"$F$F$_$^$7$?$,e(Btest/test_timeout.rbe$B$,%O%s%0$9$k$h$&$K$J$j$^$9$M!#e(B
e$B$=$3$^$G%7%s%W%k$JOC$G$b$J$5$=$&!#e(B

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

Shyouhei U. e$B$5$s$O=q$-$^$7$?e(B:

e$B%Q%C%A$"$F$F$_$^$7$?$,e(Btest/test_timeout.rbe$B$,%O%s%0$9$k$h$&$K$J$j$^$9$M!#e(B
e$B$=$3$^$G%7%s%W%k$JOC$G$b$J$5$=$&!#e(B

e$B$h$/$o$+$C$F$J$$$^$^;n9T:x8m$r7+$jJV$9$N$be(B
e$B$I$&$+$H$O;W$C$?$N$G$9$,!"e(B
e$B$?$H$([email protected]$He(Btest_timeout.rbe$B$ODL$k$h$&$G$9!#e(B

Index: eval.c

— eval.c (revision 24384)
+++ eval.c (working copy)
@@ -11378,7 +11378,7 @@
break;
}
if ((th->status == THREAD_RUNNABLE || th == th_found) &&
th->stk_ptr) {

  •       if (!next || next->priority < th->priority) {
    
  •       if (!next || next->priority < th->priority || th == th_found 
    

&& next->priority == th->priority) {
if (th == th_found) {
th_found->status = THREAD_RUNNABLE;
th_found->wait_for = 0;

e$B:#2s$Oe(Btest/runner.rbe$B$r<B9T$7$F!"%Q%C%A$"$j!&$J$7$G0c$$$,$G$J$$$H$3$m$^$G$O3NG’$7$^$7$?!#e(B

In article [email protected],
akira yamada / e$B$d$^[email protected]$"$-$ie(B [email protected] writes:

e$B$h$/$o$+$C$F$J$$$^$^;n9T:x8m$r7+$jJV$9$N$be(B
e$B$I$&$+$H$O;W$C$?$N$G$9$,!"e(B
e$B$?$H$([email protected]$He(Btest_timeout.rbe$B$ODL$k$h$&$G$9!#e(B

th_found e$B$K$O!“e(Bth_found e$B$re(B runnable e$B$K$7$?$H$-$OI,$:e(B
th_found e$B$r<!$KF0$+$9%9%l%C%I$H$7$FA*$V$H$$$&0U?^$,$”$j$^$9!#e(B
(e$B5U$K$$$($P!“e(BI/O e$BBT$A$J%9%l%C%I$N$&$A!”<!$KF0$+$9%9%l%C%I$He(B
e$B$7$FA*$P$J$$$b$N$Oe(B runnable e$B$K$O$7$J$$$H$$$&$3$H$G$9e(B)

e$BM}M3$Oe(B [ruby-core:20446]
e$B$G$9$,!"$J$s$+$&$^$/$J$$$h$&$G$9$M!#e(B

Net::SSH e$B$NLdBj$O<j85$G$O:F8=$7$J$$$N$G!"$3$NLdBj$N>u67$O$he(B
e$B$/$o$+$j$^$;$s!#e(B

% ./ruby -v -I/home/ruby/net-ssh/net-ssh-2.0.11/lib -rnet/ssh -e
‘[“localhost”,“localhost”].map {|h| Thread.new{Net::SSH.start(h,
“foo”)}}.each {|t| t.join}’
ruby 1.8.8dev (2009-08-05 revision 24403) [i686-linux]
/home/ruby/net-ssh/net-ssh-2.0.11/lib/net/ssh/ruby_compat.rb:3: warning:
method redefined; discarding old getbyte
/home/ruby/net-ssh/net-ssh-2.0.11/lib/net/ssh.rb:192:in start': foo (Net::SSH::AuthenticationFailed) from -e:1:injoin’
from -e:1
from -e:1:in `each’
from -e:1

e$B$G$b!"%3!<%I$r$$J$*$7$?$i$J$s$+JQ$J$H$3$m$r8+$D$1$?$N$G$A$g$Ce(B
e$B$HD>$7$F$
$^$7$?!#$=$l$,$3$NLdBj$rD>$9$+$I$&$+$O$o$+$j$^$;$s!#e(B

e$B%A%1%C%He(B #1848 e$B$,99?7$5$l$^$7$?!#e(B (by Akira T.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B
e$B?JD=e(B % 0e$B$+$ie(B100e$B$KJQ99e(B

Applied in changeset r24442.

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

2009/8/7 akira yamada / e$B$d$^[email protected]$"$-$ie(B [email protected]:

e$B0J2<$G!"$*$=$i$/F1$8$H;W$o$l$k8=>]$,5/$-$^$9!#e(B
e$B<j85$G$O<B9T$4$H$KKh2sH/@8$7$F$$$^$9$,!"e(B
e$B$b$7$+$9$k$H2?EY$+<B9T$9$k$H!A$+$b$7$l$^$;$s!#e(B

e$B$9$P$i$7$$!#:F8=$7$^$7$?!#e(B

e$BD>$;$?$h$&$K;W$$$^$9!#e(B

Tanaka A. e$B$5$s$O=q$-$^$7$?e(B:

Net::SSH e$B$NLdBj$O<j85$G$O:F8=$7$J$$$N$G!"$3$NLdBj$N>u67$O$he(B
e$B$/$o$+$j$^$;$s!#e(B

e$B0J2<$G!"$*$=$i$/F1$8$H;W$o$l$k8=>]$,5/$-$^$9!#e(B
e$B<j85$G$O<B9T$4$H$KKh2sH/@8$7$F$$$^$9$,!"e(B
e$B$b$7$+$9$k$H2?EY$+<B9T$9$k$H!A$+$b$7$l$^$;$s!#e(B


th = []

2.times do
th << Thread.new do
open("/dev/zero") do |i|
loop do
r, = IO.select([i], [], [], 0)
if r
p i.read(1)
break
end
end
end
end
end

th.each {|t| t.join }

e$B;29M$K$J$k$+$I$&$+$o$+$j$^$;$s$,e(Bdebug
printe$B$rF~$l$F$_$^$7$?!#e(B
[email protected],$,9THV9f$G$9!#e(B

11249 /* Do the select if needed /
11250 fprintf(stderr,"%4d) need_select=%d\n",LINE,need_select);
if (need_select) {
11251 /
Convert delay to a timeval */

11267 n = select(max+1, &readfds, &writefds, &exceptfds,
delay_ptr);
11268 fprintf(stderr,"%4d) n=%d\n",LINE,n); if (n < 0) {
11269 int e = errno;

11361 th_found = th;
11362 fprintf(stderr,"%4d) th_found=%d\n",LINE,th);
found = 1;
11363 break;

11369 th_found = th;
11370 fprintf(stderr,"%4d) th_found=%d\n",LINE,th);
found = 1;
11371 break;

11386 }
11387 fprintf(stderr,"%4d) th=%d th_found=%d\n",LINE,th,th_found);
if ((th->status == THREAD_RUNNABLE || th == th_found) && th->stk_ptr) {
11388 if (!next || next->priority < th->priority) {
11389 fprintf(stderr,"%4d) next=th\n",LINE); next = th;
11390 }

e$B<B9T7k2L$O$3$s$J46$8$K$J$j$^$9!#e(B
(e$B;HMQ$7$?$N$Oe(Bruby 1.8.8dev (2009-08-06 revision 24416)
[i686-linux]e$B$G$9e(B)

  1. need_select=1
  2. n=1
  3. th_found=142481000
  4. th=142326496 th_found=142481000
  5. next=th
  6. th=142481000 th_found=142481000
  7. need_select=1
  8. n=1
  9. th_found=142490464
  10. th=142481000 th_found=142490464
  11. next=th
  12. th=142326496 th_found=142490464
  13. th=142490464 th_found=142490464
  14. need_select=1
  15. n=1
  16. th_found=142481000
  17. th=142326496 th_found=142481000
  18. next=th
  19. th=142490464 th_found=142481000
  20. th=142481000 th_found=142481000

1.8.7-p35e$B$G$b8=>]$,H/@8$7$^$9!#e(B1.8.7-p{72,134}e$B$He(B1.9.0-p0e$B$G$O$9$0$K=*N;$7$^$9!#e(B

On 2009/08/07, at 23:47, Tanaka A. wrote:

e$B0J2<$G!"$*$=$i$/F1$8$H;W$o$l$k8=>]$,5/$-$^$9!#e(B
e$B<j85$G$O<B9T$4$H$KKh2sH/@8$7$F$$$^$9$,!"e(B
e$B$b$7$+$9$k$H2?EY$+<B9T$9$k$H!A$+$b$7$l$^$;$s!#e(B

e$B$9$P$i$7$$!#:F8=$7$^$7$?!#e(B

e$BD>$;$?$h$&$K;W$$$^$9!#e(B

e$B$"$j$,$H$&$4$6$$$^$9!#e(B
e$B<j85$G$bF0:n$,3NG’$G$-$^$7$?!#e(B

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