#794: `pthread_mutex_unlock(&t->sleep_mutex)' failed: Invalid argument (22) ----------------------------------+----------------------------------------- Reporter: watson1...@… | Owner: lsansone...@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+-----------------------------------------
Comment(by watson1...@…): It is necessary for "t->status = THREAD_DEAD" to move to the top of RoxorCore::unregister_thread().[[BR]] The reason is because it becomes the error when pthread_mutex_lock() in rb_vm_thread_cancel() is executed between pthread_mutex_destroy() and "t->status = THREAD_DEAD". {{{ #!diff diff --git a/vm.cpp b/vm.cpp index 60e6db4..1f6dc86 100644 --- a/vm.cpp +++ b/vm.cpp @@ -4291,6 +4291,9 @@ RoxorCore::unregister_thread(VALUE thread) { RoxorCoreLock lock; + rb_vm_thread_t *t = GetThreadPtr(thread); + t->status = THREAD_DEAD; + // We do not call #delete because it might trigger #== in case it has been // overriden on the thread object, and therefore cause a deadlock if the // new method tries to acquire the RoxorCore GIL. @@ -4311,8 +4314,6 @@ RoxorCore::unregister_thread(VALUE thread) lock.unlock(); - rb_vm_thread_t *t = GetThreadPtr(thread); - const int code = pthread_mutex_destroy(&t->sleep_mutex); if (code == EBUSY) { // The mutex is already locked, which means we are being called from @@ -4333,8 +4334,6 @@ RoxorCore::unregister_thread(VALUE thread) t->vm = NULL; pthread_assert(pthread_setspecific(RoxorVM::vm_thread_key, NULL)); - - t->status = THREAD_DEAD; } static inline void }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/794#comment:6> MacRuby <http://macruby.org/> _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel