#794: `pthread_mutex_unlock(&t->sleep_mutex)' failed: Invalid argument (22) ----------------------------------+----------------------------------------- Reporter: watson1...@… | Owner: lsansone...@… Type: defect | Status: reopened Priority: blocker | Milestone: MacRuby 0.7 Component: MacRuby | Resolution: Keywords: | ----------------------------------+----------------------------------------- Changes (by watson1...@…):
* 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/> _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel