[MacRuby-devel] [MacRuby] #794: `pthread_mutex_unlock(&t->sleep_mutex)' failed: Invalid argument (22)
MacRuby
ruby-noreply at macosforge.org
Fri Aug 6 16:22:57 PDT 2010
#794: `pthread_mutex_unlock(&t->sleep_mutex)' failed: Invalid argument (22)
----------------------------------+-----------------------------------------
Reporter: watson1978@… | Owner: lsansonetti@…
Type: defect | Status: reopened
Priority: blocker | Milestone: MacRuby 0.7
Component: MacRuby | Resolution:
Keywords: |
----------------------------------+-----------------------------------------
Changes (by watson1978@…):
* status: closed => reopened
* resolution: fixed =>
Comment:
Sorry. This issue reproduces as followin conditions:
* pthread_mutex_destroy() is executed between "t->status = THREAD_KILLED"
and pthread_mutex_lock() in rb_vm_thread_cancel().
* pthread_mutex_unlock() and pthread_mutex_destroy() in
unregister_thread() were executed while executed pthread_mutex_lock() in
rb_vm_thread_cancel(), assertion fails when executes
pthread_mutex_unlock() in rb_vm_thread_cancel().
So, I think that should lock the GlobalLock for exclusive control of
rb_vm_thread_cancel() and unregister_thread() while executes
rb_vm_thread_cancel().
A change of comment:6 and below will be necessary.
{{{
#!diff
diff --git a/vm.cpp b/vm.cpp
index 1edcb5d..01c9bab 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -4609,10 +4609,14 @@ extern "C"
void
rb_vm_thread_cancel(rb_vm_thread_t *t)
{
+ RoxorCoreLock lock;
+
if (t->status != THREAD_KILLED && t->status != THREAD_DEAD) {
t->status = THREAD_KILLED;
if (t->thread == pthread_self()) {
+ lock.unlock();
rb_vm_thread_throw_kill();
+ return;
}
else {
pthread_assert(pthread_mutex_lock(&t->sleep_mutex));
@@ -4631,6 +4635,7 @@ rb_vm_thread_cancel(rb_vm_thread_t *t)
pthread_assert(pthread_mutex_unlock(&t->sleep_mutex));
}
}
+ lock.unlock();
}
extern "C"
}}}
--
Ticket URL: <http://www.macruby.org/trac/ticket/794#comment:9>
MacRuby <http://macruby.org/>
More information about the MacRuby-devel
mailing list