summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-02 14:40:29 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-02 14:40:29 +0000
commit453bb57d5539e36e4672d9a1883a296a98a0126a (patch)
treee3ff9db318037f7661eee38e9018e55de8dc43d6
parent5362d2e2cb0c54c098fd2ff2f5cd0c2a2434ecb7 (diff)
merge revision(s) 39939: [Backport #8360]
* 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/branches/ruby_2_0_0@40562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--thread.c12
-rw-r--r--version.h2
3 files changed, 16 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 1f347c30e2..a3171f464d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu May 2 23:39:45 2013 Tanaka Akira <akr@fsij.org>
+
+ * thread.c (double2timeval): convert the infinity to TIME_MAX to avoid
+ SEGV by Thread.new {}.join(Float::INFINITY) on
+ Debian GNU/Linux (amd64).
+
Thu May 2 00:30:00 2013 Tanaka Akira <akr@fsij.org>
* thread_pthread.c (ruby_init_stack): Add STACK_GROW_DIR_DETECTION.
diff --git a/thread.c b/thread.c
index 60640d9445..4964605ce4 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) {
@@ -3509,9 +3518,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
diff --git a/version.h b/version.h
index 6b3657109f..9918ade327 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.0.0"
#define RUBY_RELEASE_DATE "2013-05-02"
-#define RUBY_PATCHLEVEL 180
+#define RUBY_PATCHLEVEL 181
#define RUBY_RELEASE_YEAR 2013
#define RUBY_RELEASE_MONTH 5