From 79f7521e9be53324581b5b469d1717081e67f80e Mon Sep 17 00:00:00 2001 From: akr Date: Tue, 26 Mar 2013 13:16:31 +0000 Subject: * thread.c (double2timeval): convert the infinity to TIME_MAX to avoid SEGV by Thread.new {}.join(Float::INFINITY) on Debian GNU/Linux (amd64). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ thread.c | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 35da5a8845..25dc188afb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Mar 26 22:14:46 2013 Tanaka Akira + + * thread.c (double2timeval): convert the infinity to TIME_MAX to avoid + SEGV by Thread.new {}.join(Float::INFINITY) on + Debian GNU/Linux (amd64). + Mon Mar 25 07:09:20 2013 Eric Hodel * lib/rinda/tuplespace.rb: Only return tuple entry once on move, diff --git a/thread.c b/thread.c index e9fe8a7ddf..189a563c44 100644 --- a/thread.c +++ b/thread.c @@ -73,6 +73,9 @@ #define THREAD_DEBUG 0 #endif +#define TIMET_MAX (~(time_t)0 <= 0 ? (time_t)((~(unsigned_time_t)0) >> 1) : (time_t)(~(unsigned_time_t)0)) +#define TIMET_MIN (~(time_t)0 <= 0 ? (time_t)(((unsigned_time_t)1) << (sizeof(time_t) * CHAR_BIT - 1)) : (time_t)0) + VALUE rb_cMutex; VALUE rb_cThreadShield; @@ -916,6 +919,12 @@ double2timeval(double d) { struct timeval time; + if (isinf(d)) { + time.tv_sec = TIMET_MAX; + time.tv_usec = 0; + return time; + } + time.tv_sec = (int)d; time.tv_usec = (int)((d - (int)d) * 1e6); if (time.tv_usec < 0) { @@ -3551,9 +3560,6 @@ rb_thread_fd_select(int max, rb_fdset_t * read, rb_fdset_t * write, rb_fdset_t * #define POLLOUT_SET (POLLWRBAND | POLLWRNORM | POLLOUT | POLLERR) #define POLLEX_SET (POLLPRI) -#define TIMET_MAX (~(time_t)0 <= 0 ? (time_t)((~(unsigned_time_t)0) >> 1) : (time_t)(~(unsigned_time_t)0)) -#define TIMET_MIN (~(time_t)0 <= 0 ? (time_t)(((unsigned_time_t)1) << (sizeof(time_t) * CHAR_BIT - 1)) : (time_t)0) - #ifndef HAVE_PPOLL /* TODO: don't ignore sigmask */ int -- cgit v1.2.3