1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* eval.c (rb_thread_deadlock, rb_thread_schedule, rb_thread_join): more verbose message at deadlock.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2002-09-27 09:42:24 +00:00
parent af181db784
commit cfeb0c30c4
2 changed files with 30 additions and 7 deletions

View file

@ -1,3 +1,11 @@
Fri Sep 27 18:40:42 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* eval.c (rb_thread_deadlock): more verbose message at deadlock.
* eval.c (rb_thread_schedule): ditto.
* eval.c (rb_thread_join): ditto.
Fri Sep 27 13:24:35 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_eval): Class#inherited should be called after the

29
eval.c
View file

@ -7794,12 +7794,17 @@ rb_thread_fd_close(fd)
static void
rb_thread_deadlock()
{
char msg[21+SIZEOF_LONG*2];
VALUE e;
sprintf(msg, "Thread(0x%lx): deadlock", curr_thread->thread);
e = rb_exc_new2(rb_eFatal, msg);
if (curr_thread == main_thread) {
rb_raise(rb_eFatal, "Thread: deadlock");
rb_exc_raise(e);
}
curr_thread = main_thread;
th_raise_argc = 1;
th_raise_argv[0] = rb_exc_new2(rb_eFatal, "Thread: deadlock");
th_raise_argv[0] = e;
th_raise_node = ruby_current_node;
rb_thread_restore_context(main_thread, RESTORE_RAISE);
}
@ -8066,9 +8071,17 @@ rb_thread_schedule()
/* raise fatal error to main thread */
curr_thread->node = ruby_current_node;
FOREACH_THREAD_FROM(curr, th) {
fprintf(stderr, "deadlock 0x%lx: %d:%d %s - %s:%d\n",
th->thread, th->status,
th->wait_for, th==main_thread ? "(main)" : "",
fprintf(stderr, "deadlock 0x%lx: %s:",
th->thread, thread_status_name(th->status));
if (th->wait_for & WAIT_FD) fprintf(stderr, "F(%d)", th->fd);
if (th->wait_for & WAIT_SELECT) fprintf(stderr, "S");
if (th->wait_for & WAIT_TIME) fprintf(stderr, "T(%f)", th->delay);
if (th->wait_for & WAIT_JOIN)
fprintf(stderr, "J(0x%lx)", th->join ? th->join->thread : 0);
if (th->wait_for & WAIT_PID) fprintf(stderr, "P");
if (!th->wait_for) fprintf(stderr, "-");
fprintf(stderr, " %s - %s:%d\n",
th==main_thread ? "(main)" : "",
th->node->nd_file, nd_line(th->node));
}
END_FOREACH_FROM(curr, th);
@ -8291,9 +8304,11 @@ rb_thread_join(th, limit)
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");
rb_raise(rb_eThreadError, "thread 0x%lx tried to join itself",
th->thread);
if ((th->wait_for & WAIT_JOIN) && th->join == curr_thread)
rb_raise(rb_eThreadError, "Thread#join: deadlock - mutual join");
rb_raise(rb_eThreadError, "Thread#join: deadlock 0x%lx - mutual join(0x%lx)",
curr_thread->thread, th->thread);
if (curr_thread->status == THREAD_TO_KILL)
last_status = THREAD_TO_KILL;
if (limit == 0) return Qfalse;