Bugs: Browse | Submit New | Admin

[#11795] Arity bug and possible signo bug in SignalException.new

Date:
2007-06-23 12:48
Priority:
3
Submitted By:
Daniel Berger (djberg96)
Assigned To:
Shyouhei Urabe (shyouhei)
Category:
Language / Runtime / Core Libraries
State:
Open
Platform:
 
Summary:
Arity bug and possible signo bug in SignalException.new

Detailed description
Hi,

Ruby 1.8.6

SignalException.new is supposed to take only one argument, correct? If so, there's a bug in signal.c. The arity prototype
is set to -1 for esignal_init and there's some unnecessary argc checking going on in the that function as well.

The upshot of this is that there's an arity bug:

SignalException.new        # ArgumentError, need 1 argument
SignalException.new(1)     # ok
SignalException.new(1,2)   # ok, but should raise an ArgumentError
SignalException.new(1,2,3) # ArgumentError, too many arguments

Also, is SignalException#signo supposed to be a public getter method? If so, then line 261 needs to be changed:

rb_iv_set(self, "signo", INT2NUM(signo)) => Missing "@" symbol.

If that's changed, then line 1598 in eval.c will need an equivalent change.

Attached are a diff and a test case for a cleaned up version that fixes the arity bug. I haven't touched the
"signo" instance variable, however, since I'm not sure what the desired behavior is.

Regards,

Dan

Add A Comment: Notepad

Please login


Followup

Message
Date: 2007-06-24 14:18
Sender: Daniel Berger

You should have the capability to change the description if
you don't like the current one. I cannot change it without
admin rights.

However, I'm not sure "missing type check" is correct
either. Perhaps "prototype bug".

In any case, the description makes it clear.

Dan
Date: 2007-06-24 06:30
Sender: Nobuyoshi Nakada 

It would be a missing type check, rather than an "arity
bug".

Attached Files:

Name Description Download
signal.diff Diff for signal.c Download
tc_signal_exception.rb Test case for SignalException Download

Changes:

Field Old Value Date By
File Added2152: tc_signal_exception.rb2007-06-23 12:49djberg96
File Added2151: signal.diff2007-06-23 12:48djberg96