ruby-changes:50066
From: normal <ko1@a...>
Date: Sun, 4 Feb 2018 07:24:23 +0900 (JST)
Subject: [ruby-changes:50066] normal:r62184 (trunk): thread.c (thread_join_m): avoid NUM2TIMET for Bignum
normal 2018-02-04 07:24:17 +0900 (Sun, 04 Feb 2018) New Revision: 62184 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62184 Log: thread.c (thread_join_m): avoid NUM2TIMET for Bignum Bignums exceed the range of time_t (or long). Modified files: trunk/test/ruby/test_thread.rb trunk/thread.c Index: thread.c =================================================================== --- thread.c (revision 62183) +++ thread.c (revision 62184) @@ -1040,7 +1040,6 @@ thread_join_m(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/thread.c#L1040 switch (TYPE(limit)) { case T_NIL: break; case T_FIXNUM: - case T_BIGNUM: timeval.tv_sec = NUM2TIMET(limit); timeval.tv_usec = 0; tv = &timeval; Index: test/ruby/test_thread.rb =================================================================== --- test/ruby/test_thread.rb (revision 62183) +++ test/ruby/test_thread.rb (revision 62184) @@ -1,6 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L1 # -*- 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L228 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/