------ 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 class soNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">Hi All</span></font></div>
<div class soNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font> </div>
<div class soNormal"><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 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.
</span></font></div>
<div class soNormal"><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. </span></font>
</div>
<div class soNormal"><font face
rial" colorlue" size"><span langホ「 ONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font> </div>
<div class soNormal"><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"> </span></font></div>
<div class soNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font> </div>
<div class soNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">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().
</span></font></div>
<div class soNormal"><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 no signal handler should be installed for it.</span></font><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">
</span></font></div>
<p class soNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">2. Handling SIGINT </span></font></p>
<div class soNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">"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").
</span></font></div>
<div class soNormal"><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" colorlue" 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 class soNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font></p>
<div class soNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">Existing code of ruby_sig_finalize is following:</span></font></div>
<div class soNormal"><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">
---------------------------------------------------------------------------------------------</span></font></div>
<div class soNormal"><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">
void ruby_sig_finalize()</span></font></div>
<div class soNormal"><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">
{</span></font></div>
<div class soNormal"><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">
sighandler_t oldfunc;</span></font></div>
<div class soNormal"><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">
oldfunc uby_signal(SIGINT, SIG_IGN);</span></font></div>
<div class soNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"> if (oldfunc sighandler) {</span></font></div>
<div class soNormal"><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">
ruby_signal(SIGINT, SIG_DFL);</span></font></div>
<div class soNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"> }</span></font></div>
<div class soNormal"><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">
}</span></font></div>
<div class soNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font> </div>
<div class soNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">We can do below correction in ruby_sig_finalize function:</span></font></div>
<div class soNormal"><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">
---------------------------------------------------------------------------------------------</span></font></div>
<div class soNormal"><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">
void ruby_sig_finalize()</span></font></div>
<div class soNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">{</span></font></div>
<div class soNormal"><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">
sighandler_t oldfunc;</span></font></div>
<div class soNormal"><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">
oldfunc uby_signal(SIGINT, SIG_DFL);</span></font></div>
<div class soNormal"><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">
if (oldfunc ! ighandler) {</span></font></div>
<div class soNormal"><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">
ruby_signal(SIGINT, oldfunc);</span></font></div>
<div class soNormal"><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">
}</span></font></div>
<div class soNormal"><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">
} </span></font></div>
<div class soNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font> </div>
<div class soNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></span></font><font face
rial" color avy" size"><span styleONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">
</span></font></div>
<div class soNormal"><font face
rial" colorlue" size"><span styleONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">Regards</span></font></div>
<div class soNormal"><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">
Chirag</span></font></div><br><br>
<div><span class mail_quote">On 12/20/07, <b class mail_sendername">Chirag Mistry</b> <<a href ailto:chirag80bece / gmail.com">chirag80bece / gmail.com</a>> wrote:</span>
<blockquote class mail_quote" style ADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div><span class " id _116f6b512db7be56_0">
<div> </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. </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> </div>
<div>Regards</div>
<div>Chirag</div></span></div></blockquote></div><br>
------ art_7873_978146.1200898156765--