[macruby-changes] [3236] MacRuby/trunk/vm.cpp
source_changes at macosforge.org
source_changes at macosforge.org
Sun Jan 10 21:57:29 PST 2010
Revision: 3236
http://trac.macosforge.org/projects/ruby/changeset/3236
Author: lsansonetti at apple.com
Date: 2010-01-10 21:57:28 -0800 (Sun, 10 Jan 2010)
Log Message:
-----------
don't use #delete to remove a thread from the internal list since it might trigger custom methods which might acquire the GIL and therefore cause a deadlock
Modified Paths:
--------------
MacRuby/trunk/vm.cpp
Modified: MacRuby/trunk/vm.cpp
===================================================================
--- MacRuby/trunk/vm.cpp 2010-01-11 05:55:21 UTC (rev 3235)
+++ MacRuby/trunk/vm.cpp 2010-01-11 05:57:28 UTC (rev 3236)
@@ -4257,7 +4257,19 @@
RoxorCore::unregister_thread(VALUE thread)
{
lock();
- if (rb_ary_delete(threads, thread) != thread) {
+ // 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.
+ bool deleted = false;
+ for (long i = 0, n = RARRAY_LEN(threads); i < n; i++) {
+ VALUE ti = RARRAY_AT(threads, i);
+ if (ti == thread) {
+ rb_ary_delete_at(threads, i);
+ deleted = true;
+ break;
+ }
+ }
+ if (!deleted) {
printf("trying to unregister a thread (%p) that was never registered!",
(void *)thread);
abort();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100110/9bda4fe0/attachment.html>
More information about the macruby-changes
mailing list