mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
thread.c (thread_join_m): avoid NUM2TIMET for Bignum
Bignums exceed the range of time_t (or long). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c0e2f98f9b
commit
05c18139a1
2 changed files with 9 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
# -*- coding: us-ascii -*-
|
||||
# frozen_string_literal: false
|
||||
require 'test/unit'
|
||||
require "rbconfig/sizeof"
|
||||
|
||||
class TestThread < Test::Unit::TestCase
|
||||
class Thread < ::Thread
|
||||
|
@ -227,6 +228,14 @@ class TestThread < Test::Unit::TestCase
|
|||
t3.kill if t3
|
||||
end
|
||||
|
||||
def test_join_limits
|
||||
[ RbConfig::LIMITS['FIXNUM_MAX'], RbConfig::LIMITS['UINT64_MAX'],
|
||||
Float::INFINITY ].each do |limit|
|
||||
t = Thread.new {}
|
||||
assert_same t, t.join(limit), "limit=#{limit.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
def test_kill_main_thread
|
||||
assert_in_out_err([], <<-INPUT, %w(1), [])
|
||||
p 1
|
||||
|
|
1
thread.c
1
thread.c
|
@ -1040,7 +1040,6 @@ thread_join_m(int argc, VALUE *argv, VALUE self)
|
|||
switch (TYPE(limit)) {
|
||||
case T_NIL: break;
|
||||
case T_FIXNUM:
|
||||
case T_BIGNUM:
|
||||
timeval.tv_sec = NUM2TIMET(limit);
|
||||
timeval.tv_usec = 0;
|
||||
tv = &timeval;
|
||||
|
|
Loading…
Reference in a new issue