matz / ruby-lang.org (Yukihiro Matsumoto) writes: > Hi, > > In message "[ruby-talk:25417] Re: BUG? Solaris select or poll does not recover correctly when signaled" > on 01/11/16, Ville Mattila <mulperi / iki.fi> writes: > > |> Can you try to protect all call to select(2) in eval.c against > |> ERESTART. > > | I did this modification to rb_thread_select and Invalid socket > | problem seems to be gone. Thank you very much! This > | fix is probably correct on Solaris, as for example solaris 8 > | source code includes similar check in truss program. > > I will merge this modification. Thank you, Guy. Unfortunaly this modification does not fix the problem. I should have done tests a bit longer. Anyway here is the current situtation: I have modified eval.c and every other source file where EINTR is handled to handle ERESTART too. Also I have done a little modificatoin to rb_thread_select to report errno if it is not EINTR or ERESTART. I think we handle SA_RESTART signal flag somehow wrongly when it comes VTALRM and ruby thread time slicing. Here is the current std and truss output. cc -static -o sbfcfilter sbfcfilter-2.2.19-7.0.12.o rb_thread_select ERROR 22 in SELECT Invalid argument /sb/tb/toolbox3/sparc-sun-solaris2.5.1/lib/ruby/1.6/net/telnet.rb:464:in `select ' /sb/tb/toolbox3/sparc-sun-solaris2.5.1/lib/ruby/1.6/net/telnet.rb:464:in `waitfo r' /sb/tb/toolbox3/sparc-sun-solaris2.5.1/lib/ruby/1.6/net/telnet.rb:552:in `cmd' /sb/dev/work/releases/sbtools/product.rb:335:in `telnet_build' /sb/dev/work/releases/sbtools/product.rb:125:in `build' ../sbtools/sbfcmake.rb:545:in `main' ../sbtools/sbfcmake.rb:545:in `each' ../sbtools/sbfcmake.rb:545:in `main' ../sbtools/sbfcmake.rb:544:in `each' ../sbtools/sbfcmake.rb:544:in `main' ../sbtools/sbfcmake.rb:560 Trying linux-c... Connected to linux-c. Truss output ( a bit longer that people can get a big picture 8-)): 11624: Received signal #28, SIGVTALRM [caught] 11624: setcontext(0xFFBEA600) 11624: write(1, " c c $ ( M C F L A G S".., 52) = 52 11624: Received signal #28, SIGVTALRM [caught] 11624: setcontext(0xFFBEAAC0) 11624: Received signal #28, SIGVTALRM [caught] 11624: setcontext(0xFFBEAAC0) 11624: poll(0xFFBEA8B8, 1, 480000) (sleeping...) 11624: poll(0xFFBEA8B8, 1, 480000) = 1 11624: fd=4 ev=POLLRDNORM rev=POLLRDNORM 11624: read(4, " l d - r - X - x ".., 1048576) = 994 11624: write(1, " l d - r - X - x ".., 993) = 993 11624: Received signal #28, SIGVTALRM [caught] 11624: setcontext(0xFFBEA9B8) 11624: Received signal #28, SIGVTALRM [caught] 11624: setcontext(0xFFBEAAC0) 11624: Received signal #28, SIGVTALRM [caught] 11624: setcontext(0xFFBEAAC0) 11624: poll(0xFFBEA8B8, 1, 480000) (sleeping...) 11624: poll(0xFFBEA8B8, 1, 480000) = 1 11624: fd=4 ev=POLLRDNORM rev=POLLRDNORM 11624: read(4, " c p s b i f . m - 2 .".., 1048576) = 49 11624: write(1, " c p s b i f . m - 2 .".., 48) = 48 11624: Received signal #28, SIGVTALRM [caught] 11624: setcontext(0xFFBEAAC0) 11624: poll(0xFFBEA8B8, 1, 480000) = 1 11624: fd=4 ev=POLLRDNORM rev=POLLRDNORM 11624: read(4, " c c - I / u s r / i n".., 1048576) = 82 11624: write(1, " c c - I / u s r / i n".., 81) = 81 11624: Received signal #28, SIGVTALRM [caught] 11624: setcontext(0xFFBEAAC0) 11624: Received signal #28, SIGVTALRM [caught] 11624: setcontext(0xFFBEAAC0) 11624: poll(0xFFBEA8B8, 1, 480000) = 1 11624: fd=4 ev=POLLRDNORM rev=POLLRDNORM 11624: read(4, " c c - s t a t i c ".., 1048576) = 54 11624: write(1, " c c - s t a t i c ".., 53) = 53 To this point it's business as usual. 11624: Received signal #28, SIGVTALRM [caught] 11624: setcontext(0xFFBEAA28) 11624: Received signal #28, SIGVTALRM [caught] 11624: setcontext(0xFFBEAAC0) 11624: Received signal #28, SIGVTALRM, in poll() [caught] 11624: poll(0xFFBEA8B8, 1, 480000) Err#91 ERESTART 11624: fd=4 ev=POLLRDNORM rev=0x4057 Put here we get SIGVTALARM in poll and the problem appears. rb_therad_select's select get's EINVAL not ERESTART. 11624: setcontext(0xFFBEA5A0) 11624: write(2, " r b _ t h r e a d _ s e".., 23) = 23 11624: write(2, " 2 2", 2) = 2 11624: write(2, " i n S E L E C T\n", 11) = 11 11624: sigprocmask(SIG_SETMASK, 0x000BD2E0, 0x00000000) = 0 11624: set = 0 0 0 0 11624: write(1, " I n v a l i d a r g u".., 17) = 17 11624: write(1, " / s b / t b / t o o l b".., 82) = 82 11624: write(1, " / s b / t b / t o o l b".., 83) = 83 11624: write(1, " / s b / t b / t o o l b".., 79) = 79 11624: write(1, " / s b / d e v / w o r k".., 63) = 63 11624: write(1, " / s b / d e v / w o r k".., 56) = 56 11624: write(1, " . / s b t o o l s / s b".., 36) = 36 11624: write(1, " . / s b t o o l s / s b".., 36) = 36 11624: write(1, " . / s b t o o l s / s b".., 36) = 36 11624: write(1, " . / s b t o o l s / s b".., 36) = 36 11624: write(1, " . / s b t o o l s / s b".., 36) = 36 11624: write(1, " . / s b t o o l s / s b".., 26) = 26 11624: write(1, " T r y i n g l i n u x".., 18) = 18 11624: time() = 1006110413 11624: poll(0xFFBE8DB8, 0, 0) = 0 11624: door_info(3, 0xFFBE7260) = 0 11624: door_call(3, 0xFFBE7248) = 0 11624: so_socket(2, 2, 6, "", 1) = 6 11624: fcntl(6, F_GETFL, 0x00000000) = 2 11624: fstat64(6, 0xFFBE93F8) = 0 11624: d=0x02EC0000 i=34740 m=0140666 l=0 u=0 g=0 sz=0 11624: at = Nov 18 21:06:53 EET 2001 [ 1006110413 ] 11624: mt = Nov 18 21:06:53 EET 2001 [ 1006110413 ] 11624: ct = Nov 18 21:06:53 EET 2001 [ 1006110413 ] 11624: bsz=8192 blks=0 fs=ufs 11624: getsockopt(6, 65535, 8192, 0xFFBE94F8, 0xFFBE94F0, 3046396) =