------art_7873_978146.1200898156765
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi All

We had given some inputs for the signal usage in Ruby 1.9 based on our study
of the earlier version of Ruby 1.9 code. We have again analyzed the latest
code of Ruby 1.9 for the defects that we found during our initial
investigation of earlier version of Ruby 1.9 code. We have observed some
changes in the latest code and have accordingly modified the defect
description to reflect the latest code and new line numbers.
Given below are the updated defect descriptions for the signal usage in Ruby
1.9 implementation. It would be better to fix these defects if our
understanding is correct. Please give your feedback on the same.

1. In file trunk/thread_pthread.c, at line no: 153

In the "Init_native_thread" function, posix_signal function is called with
SIGVTALRM value setting an empty function as signal handler.
The "Init_native_thread" function is indirectly called from ruby_init().
As per our understanding, SIGVTALRM is no longer a reserved signal in Ruby
1.9 implementation and therefore no signal handler should be installed for
it.

2. Handling SIGINT
"ruby_finalize_1"(In file trunk/eval.c, at line no: 142) function
calls "ruby_sig_finalize function" (In file trunk/signal.c, at line no:
996). In "ruby_sig_finalize", signal handler SIG_IGN is installed for SIGINT
signal and then signal handler SIG_DFL is installed for SIGINT signal if the
previously installed signal handler was the Ruby handler ("sighandler").
As per our understanding, it may create problem when ruby interpreter is
embedded in a process for a limited period of time. It should not install
signal handler SIG_IGN for SIGINT signal.

Existing code of ruby_sig_finalize is following:
---------------------------------------------------------------------------------------------
void ruby_sig_finalize()
{
    sighandler_t oldfunc;
    oldfunc  uby_signal(SIGINT, SIG_IGN);
    if (oldfunc sighandler) {
            ruby_signal(SIGINT, SIG_DFL);
    }
}

We can do below correction in ruby_sig_finalize function:
---------------------------------------------------------------------------------------------
void ruby_sig_finalize()
{
    sighandler_t oldfunc;
    oldfunc  uby_signal(SIGINT, SIG_DFL);
    if (oldfunc ! ighandler) {
            ruby_signal(SIGINT, oldfunc);
    }
}


Regards
Chirag


On 12/20/07, Chirag Mistry <chirag80bece / gmail.com> wrote:
>
>
> We have study the code of yarv (Ruby 1.9 implementation) and as per our
> understanding there are few defects related to signal usage in Ruby 1.9
> implementation. Please give feedback on it.
>
> 1. In file trunk/signal.c, at line number 788:
> SIGVTALRM seems a reserved signal in the ruby interpreter as per
> implementation of trap function of Signal module. But, we did not find
> any reference related with usage of this signal. In earlier versions of
> ruby, SIGVTALRM was used to implement cooperative multitasking (user
> space multithreading) and this signal was reserved for proper
> functioning of Thread module. So in Ruby 1.9, SIGVTALRM is not used any
> more. Empty signal handler is installed for SIGVTALRM in
> Init_native_thread() function.
>
> 2. In file trunk/eval.c, at line number 144:
> In ruby_finalize_1 function, signal handler SIG_DFL is installed for
> SIGINT signal. It gets called automatically when ruby interpreter is
> unloaded (normally or abnormally).
> It may create problem when ruby interpreter is embedded in a process for
> a limited period of time. Because ruby_finalize_1 sets signal handler
> for SIGINT to SIG_DFL without checking previously installed signal
> handler.
>
> Regards
> Chirag
>

------art_7873_978146.1200898156765
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<div classsoNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">Hi All</span></font></div>
<div classsoNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font>&nbsp;</div>
<div classsoNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">We had given some inputs for the signal usage in Ruby 1.9 based on our study of the earlier version of Ruby 
1.9 code. We&nbsp;have again analyzed the latest code of Ruby 1.9 for the defects that we found&nbsp;during our initial investigation of&nbsp;earlier version of Ruby 1.9 code.&nbsp;We have observed some changes in the latest code and have accordingly modified the defect description&nbsp;to reflect the latest code and new line numbers.
</span></font></div>
<div classsoNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face
rial" colorlue" size"><span langホ「 ONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">
Given below are the updated defect descriptions for the signal usage in Ruby 1.9 implementation. It would be better to fix these defects if our understanding is correct. Please give your feedback on the same.&nbsp;</span></font>
</div>
<div classsoNormal"><font face
rial" colorlue" size"><span langホ「 ONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font>&nbsp;</div>
<div classsoNormal"><font face
rial" colorlue" size"><span langホ「 ONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">
1. In file trunk/thread_pthread.c, at line no: 153</span></font><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">&nbsp;</span></font></div>
<div classsoNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font>&nbsp;</div>
<div classsoNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">In&nbsp;the &quot;Init_native_thread&quot; function, posix_signal function is called with SIGVTALRM value&nbsp;setting&nbsp;an empty function as signal handler. The&nbsp;&quot;Init_native_thread&quot; function is indirectly called from ruby_init(). 
</span></font></div>
<div classsoNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">
As per our understanding, SIGVTALRM is no longer a reserved signal in Ruby 1.9 implementation and therefore&nbsp;no signal handler should be installed for it.</span></font><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">
&nbsp;</span></font></div>
<p classsoNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">2.&nbsp;Handling SIGINT&nbsp;</span></font></p>
<div classsoNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">&quot;ruby_finalize_1&quot;(In file trunk/eval.c, at line no: 142) function calls&nbsp;&quot;ruby_sig_finalize function&quot; (In file trunk/signal.c, at line no: 996). In&nbsp;&quot;ruby_sig_finalize&quot;, signal handler SIG_IGN is installed for SIGINT signal and then signal handler SIG_DFL&nbsp;is installed for SIGINT signal if&nbsp;the previously installed signal handler&nbsp;was&nbsp;the Ruby handler (&quot;sighandler&quot;).
</span></font></div>
<div classsoNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">
As per our understanding, it may create problem when ruby interpreter is embedded in a process for a limited period of time.</span></font><font face
rial" colorlue"><span style
OLOR: blue; FONT-FAMILY: Arial"> </span> </font><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">It should not install signal handler SIG_IGN for SIGINT signal.</span></font></div> <p classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font></p> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">Existing code of ruby_sig_finalize is following:</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"> ---------------------------------------------------------------------------------------------</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"> void ruby_sig_finalize()</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"> {</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"> &nbsp;&nbsp;&nbsp; sighandler_t oldfunc;</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"> &nbsp;&nbsp;&nbsp; oldfunc uby_signal(SIGINT, SIG_IGN);</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">&nbsp;&nbsp;&nbsp; if (oldfunc sighandler) {</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ruby_signal(SIGINT, SIG_DFL);</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">&nbsp;&nbsp;&nbsp; }</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"> }</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font>&nbsp;</div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">We can do below correction in ruby_sig_finalize function:</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"> ---------------------------------------------------------------------------------------------</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"> void ruby_sig_finalize()</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">{</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"> &nbsp;&nbsp;&nbsp; sighandler_t oldfunc;</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"> &nbsp;&nbsp;&nbsp; oldfunc uby_signal(SIGINT, SIG_DFL);</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"> &nbsp;&nbsp;&nbsp; if (oldfunc ! ighandler) {</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ruby_signal(SIGINT, oldfunc);</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"> &nbsp;&nbsp;&nbsp; }</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"> }&nbsp;</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font>&nbsp;</div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face rial" coloravy" size"><span styleONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> &nbsp;</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">Regards</span></font></div> <div classsoNormal"><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face rial" color lue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"> Chirag</span></font></div><br><br> <div><span classmail_quote">On 12/20/07, <b classmail_sendername">Chirag Mistry</b> &lt;<a hrefailto:chirag80bece / gmail.com">chirag80bece / gmail.com</a>&gt; wrote:</span> <blockquote classmail_quote" styleADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"> <div><span class" id_116f6b512db7be56_0"> <div>&nbsp;</div> <div>We have study the code of yarv (Ruby 1.9 implementation) and as per our<br>understanding there are few defects related to signal usage in Ruby 1.9<br>implementation. Please give feedback on it.&nbsp;</div> <div><br>1. In file trunk/signal.c, at line number 788:<br>SIGVTALRM seems a reserved signal in the ruby interpreter as per<br>implementation of trap function of Signal module. But, we did not find<br>any reference related with usage of this signal. In earlier versions of <br>ruby, SIGVTALRM was used to implement cooperative multitasking (user<br>space multithreading) and this signal was reserved for proper<br>functioning of Thread module. So in Ruby 1.9, SIGVTALRM is not used any<br>more. Empty signal handler is installed for SIGVTALRM in <br>Init_native_thread() function.<br><br>2. In file trunk/eval.c, at line number 144:<br>In ruby_finalize_1 function, signal handler SIG_DFL is installed for<br>SIGINT signal. It gets called automatically when ruby interpreter is <br>unloaded (normally or abnormally).<br>It may create problem when ruby interpreter is embedded in a process for<br>a limited period of time. Because ruby_finalize_1 sets signal handler<br>for SIGINT to SIG_DFL without checking previously installed signal <br>handler.</div> <div>&nbsp;</div> <div>Regards</div> <div>Chirag</div></span></div></blockquote></div><br> ------art_7873_978146.1200898156765--