From 32d0e703297ef4d7270aa5a64d7e02c9316f700c Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 29 Dec 2000 03:48:38 +0000 Subject: [PATCH] * gc.c (mem_error): prohibit recursive mem_error(). (ruby-bugs-ja:PR#36) * eval.c (rb_thread_fd_writable): should not switch context if rb_thread_critical is set. * eval.c (rb_thread_wait_fd): ditto. * eval.c (rb_thread_wait_for): ditto. * eval.c (rb_thread_select): ditto. * eval.c (rb_thread_join): join during critical section causes deadlock. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 21 ++++++++++++++++++++- eval.c | 13 +++++++++---- ext/sdbm/_sdbm.c | 4 +--- gc.c | 9 ++++++++- version.h | 4 ++-- 5 files changed, 40 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 647ddd2b4a..4408653cc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +Fri Dec 29 11:41:55 2000 Yukihiro Matsumoto + + * gc.c (mem_error): prohibit recursive mem_error(). + (ruby-bugs-ja:PR#36) + +Fri Dec 29 11:05:41 2000 Yukihiro Matsumoto + + * eval.c (rb_thread_fd_writable): should not switch context if + rb_thread_critical is set. + + * eval.c (rb_thread_wait_fd): ditto. + + * eval.c (rb_thread_wait_for): ditto. + + * eval.c (rb_thread_select): ditto. + + * eval.c (rb_thread_join): join during critical section causes + deadlock. + Tue Dec 26 18:46:41 2000 NAKAMURA Hiroshi * lib/debug.rb: Avoid thread deadlock in debugging stopped thread. @@ -116,7 +135,7 @@ Tue Dec 19 13:44:50 2000 K.Kosako Tue Dec 19 00:57:10 2000 Yukihiro Matsumoto - * time.c (time_minus): usec might overflow (ruby-bugs-ja:#PR#35). + * time.c (time_minus): usec might overflow. (ruby-bugs-ja:PR#35) * eval.c (rb_obj_extend): Object#extend should take at least one argument. diff --git a/eval.c b/eval.c index ae2ce62da9..a29538eeff 100644 --- a/eval.c +++ b/eval.c @@ -7349,6 +7349,7 @@ void rb_thread_wait_fd(fd) int fd; { + if (rb_thread_critical) return; if (curr_thread == curr_thread->next) return; if (curr_thread->status == THREAD_TO_KILL) return; @@ -7362,6 +7363,7 @@ int rb_thread_fd_writable(fd) int fd; { + if (rb_thread_critical) return Qtrue; if (curr_thread == curr_thread->next) return Qtrue; if (curr_thread->status == THREAD_TO_KILL) return Qtrue; @@ -7382,7 +7384,8 @@ rb_thread_wait_for(time) { double date; - if (curr_thread == curr_thread->next || + if (rb_thread_critical || + curr_thread == curr_thread->next || curr_thread->status == THREAD_TO_KILL) { int n; #ifndef linux @@ -7447,7 +7450,8 @@ rb_thread_select(max, read, write, except, timeout) (double)timeout->tv_sec+(double)timeout->tv_usec*1e-6; } - if (curr_thread == curr_thread->next || + if (rb_thread_critical || + curr_thread == curr_thread->next || curr_thread->status == THREAD_TO_KILL) { #ifndef linux struct timeval tv, *tvp = timeout; @@ -7513,6 +7517,7 @@ rb_thread_join(thread) rb_thread_t th = rb_thread_check(thread); enum thread_status last_status = THREAD_RUNNABLE; + if (rb_thread_critical) rb_thread_deadlock(); if (!rb_thread_dead(th)) { if (th == curr_thread) rb_raise(rb_eThreadError, "thread tried to join itself"); @@ -7612,8 +7617,8 @@ rb_thread_kill(thread) rb_thread_ready(th); th->gid = 0; th->status = THREAD_TO_KILL; - rb_thread_schedule(); - return Qnil; /* not reached */ + if (!rb_thread_critical) rb_thread_schedule(); + return thread; } static VALUE diff --git a/ext/sdbm/_sdbm.c b/ext/sdbm/_sdbm.c index 7a31472930..92c96f26d0 100644 --- a/ext/sdbm/_sdbm.c +++ b/ext/sdbm/_sdbm.c @@ -103,11 +103,9 @@ static int duppair proto((char *, datum)); /* * externals */ -#ifndef sun -#ifndef MSDOS +#if !defined(sun) && !defined(MSDOS) && !defined(_WIN32) extern int errno; #endif -#endif /* * forward diff --git a/gc.c b/gc.c index a3578aef2f..6015b81e0a 100644 --- a/gc.c +++ b/gc.c @@ -53,10 +53,17 @@ static void mem_error(mesg) char *mesg; { + static int recurse = 0; + if (rb_safe_level() >= 4) { rb_raise(rb_eNoMemError, mesg); } - rb_fatal(mesg); + if (recurse == 0) { + recurse++; + rb_fatal(mesg); + } + fprintf(stderr, "[FATAL] failed to allocate memory\n"); + exit(1); } void * diff --git a/version.h b/version.h index 71d484b8fd..4d5897c2e2 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.6.2" -#define RUBY_RELEASE_DATE "2000-12-25" +#define RUBY_RELEASE_DATE "2000-12-29" #define RUBY_VERSION_CODE 162 -#define RUBY_RELEASE_CODE 20001225 +#define RUBY_RELEASE_CODE 20001229