[MacRuby-devel] [MacRuby] #794: `pthread_mutex_unlock(&t->sleep_mutex)' failed: Invalid argument (22)
MacRuby
ruby-noreply at macosforge.org
Mon Aug 2 01:17:00 PDT 2010
#794: `pthread_mutex_unlock(&t->sleep_mutex)' failed: Invalid argument (22)
----------------------------------+-----------------------------------------
Reporter: watson1978@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: blocker | Milestone:
Component: MacRuby | Keywords:
----------------------------------+-----------------------------------------
Comment(by watson1978@…):
An error occurs when pthread_mutex_destroy() is executed in
RoxorCore::unregister_thread() right before MacRuby execute
pthread_mutex_lock() in rb_vm_thread_cancel().[[BR]]
So, I guess that should not use pthread_assert() in rb_vm_thread_cancel().
I do not yet understand why MacRuby do such a operation.
{{{
#!diff
diff --git a/vm.cpp b/vm.cpp
index 60e6db4..649f6d3 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -4580,7 +4580,10 @@ rb_vm_thread_cancel(rb_vm_thread_t *t)
rb_vm_thread_throw_kill();
}
else {
- pthread_assert(pthread_mutex_lock(&t->sleep_mutex));
+ int code = pthread_mutex_lock(&t->sleep_mutex);
+ if(code == EINVAL) {
+ return;
+ }
if (t->in_cond_wait) {
// We are trying to kill a thread which is currently
waiting
// for a condition variable (#sleep). Instead of canceling
the
@@ -4588,12 +4591,12 @@ rb_vm_thread_cancel(rb_vm_thread_t *t)
// will autodestroy itself, to work around a stack
unwinding
// bug in the Mac OS X pthread implementation that messes
our
// C++ exception handlers.
- pthread_assert(pthread_cond_signal(&t->sleep_cond));
+ pthread_cond_signal(&t->sleep_cond);
}
else {
- pthread_assert(pthread_cancel(t->thread));
+ pthread_cancel(t->thread);
}
- pthread_assert(pthread_mutex_unlock(&t->sleep_mutex));
+ pthread_mutex_unlock(&t->sleep_mutex);
}
}
}
}}}
--
Ticket URL: <http://www.macruby.org/trac/ticket/794#comment:4>
MacRuby <http://macruby.org/>
More information about the MacRuby-devel
mailing list