Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion re.c
Original file line number Diff line number Diff line change
Expand Up @@ -3971,7 +3971,7 @@ static void
set_timeout(rb_hrtime_t *hrt, VALUE timeout)
{
double timeout_d = NIL_P(timeout) ? 0.0 : NUM2DBL(timeout);
if (!NIL_P(timeout) && timeout_d <= 0) {
if (!NIL_P(timeout) && !(timeout_d > 0)) {
rb_raise(rb_eArgError, "invalid timeout: %"PRIsVALUE, timeout);
}
double2hrtime(hrt, timeout_d);
Expand Down
8 changes: 8 additions & 0 deletions scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,10 +680,14 @@ rb_fiber_scheduler_unblock(VALUE scheduler, VALUE blocker, VALUE fiber)
int saved_interrupt_mask = ec->interrupt_mask;
ec->interrupt_mask |= PENDING_INTERRUPT_MASK;

rb_control_frame_t *volatile cfp = ec->cfp;
EC_PUSH_TAG(ec);
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
result = rb_funcall(scheduler, id_unblock, 2, blocker, fiber);
}
else {
rb_vm_rewind_cfp(ec, cfp);
}
EC_POP_TAG();

ec->interrupt_mask = saved_interrupt_mask;
Expand Down Expand Up @@ -1145,10 +1149,14 @@ VALUE rb_fiber_scheduler_fiber_interrupt(VALUE scheduler, VALUE fiber, VALUE exc
int saved_interrupt_mask = ec->interrupt_mask;
ec->interrupt_mask |= PENDING_INTERRUPT_MASK;

rb_control_frame_t *volatile cfp = ec->cfp;
EC_PUSH_TAG(ec);
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
result = rb_check_funcall(scheduler, id_fiber_interrupt, 2, arguments);
}
else {
rb_vm_rewind_cfp(ec, cfp);
}
EC_POP_TAG();

ec->interrupt_mask = saved_interrupt_mask;
Expand Down
2 changes: 2 additions & 0 deletions test/ruby/test_regexp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,7 @@ def test_s_timeout_corner_cases
Regexp.timeout = 1e300
assert_equal(((1<<64)-1) / 1000000000.0, Regexp.timeout)

assert_raise(ArgumentError) { Regexp.timeout = Float::NAN }
assert_raise(ArgumentError) { Regexp.timeout = 0 }
assert_raise(ArgumentError) { Regexp.timeout = -1 }

Expand Down Expand Up @@ -2127,6 +2128,7 @@ def test_timeout_corner_cases

assert_equal(((1<<64)-1) / 1000000000.0, Regexp.new("foo", timeout: 1e300).timeout)

assert_raise(ArgumentError) { Regexp.new("foo", timeout: Float::NAN) }
assert_raise(ArgumentError) { Regexp.new("foo", timeout: 0) }
assert_raise(ArgumentError) { Regexp.new("foo", timeout: -1) }
end;
Expand Down