[#10492] Ruby 1.8.6 preview3 has been released — "Akinori MUSHA" <knu@...>

Hi,

26 messages 2007/03/04
[#10500] Re: Ruby 1.8.6 preview3 has been released — Hugh Sasse <hgs@...> 2007/03/05

On Mon, 5 Mar 2007, Akinori MUSHA wrote:

[#10507] Dynamic Array#join with block — <noreply@...>

Patches item #9055, was opened at 2007-03-05 19:57

12 messages 2007/03/05
[#10520] Re: [ ruby-Patches-9055 ] Dynamic Array#join with block — Nobuyoshi Nakada <nobu@...> 2007/03/06

Hi,

[#10594] grave bug in 1.8.6's thread implementation — Sylvain Joyeux <sylvain.joyeux@...4x.org>

In ext/thread/thread.c, remove_one leaves the list in an inconsistent state.

15 messages 2007/03/14
[#10596] Re: [PATCH] grave bug in 1.8.6's thread implementation — MenTaLguY <mental@...> 2007/03/14

On Thu, 15 Mar 2007 00:15:57 +0900, Sylvain Joyeux <sylvain.joyeux@m4x.org> wrote:

[#10597] Re: [PATCH] grave bug in 1.8.6's thread implementation — Sylvain Joyeux <sylvain.joyeux@...4x.org> 2007/03/14

> > The fix is in thread-mutex-remove_one.diff.

[#10598] Re: [PATCH] grave bug in 1.8.6's thread implementation — MenTaLguY <mental@...> 2007/03/14

On Thu, 15 Mar 2007 01:19:04 +0900, Sylvain Joyeux <sylvain.joyeux@m4x.org> wrote:

[#10599] Re: [PATCH] grave bug in 1.8.6's thread implementation — Sylvain Joyeux <sylvain.joyeux@...4x.org> 2007/03/14

On Wednesday 14 March 2007 17:29, MenTaLguY wrote:

[#10600] Re: [PATCH] grave bug in 1.8.6's thread implementation — MenTaLguY <mental@...> 2007/03/14

On Thu, 15 Mar 2007 01:48:42 +0900, Sylvain Joyeux <sylvain.joyeux@m4x.org> wrote:

[#10615] Multiton in standard library — TRANS <transfire@...>

Hi--

16 messages 2007/03/15
[#10619] Re: Multiton in standard library — Tom Pollard <tomp@...> 2007/03/16

[#10620] Re: Multiton in standard library — TRANS <transfire@...> 2007/03/16

On 3/15/07, Tom Pollard <tomp@earthlink.net> wrote:

[#10646] Marshal.dump shouldn't complain about singletons if the _dump method is defined — <noreply@...>

Bugs item #9376, was opened at 2007-03-19 15:58

12 messages 2007/03/19
[#10647] Re: [ ruby-Bugs-9376 ] Marshal.dump shouldn't complain about singletons if the _dump method is defined — Urabe Shyouhei <shyouhei@...> 2007/03/19

noreply@rubyforge.org wrote:

[#10648] Re: [ ruby-Bugs-9376 ] Marshal.dump shouldn't complain about singletons if the _dump method is defined — Sylvain Joyeux <sylvain.joyeux@...4x.org> 2007/03/19

On Monday 19 March 2007 18:01, Urabe Shyouhei wrote:

[#10651] Re: [ ruby-Bugs-9376 ] Marshal.dump shouldn't complain about singletons if the _dump method is defined — Yukihiro Matsumoto <matz@...> 2007/03/19

Hi,

[#10665] Re: [ ruby-Bugs-9376 ] Marshal.dump shouldn't complain about singletons if the _dump method is defined — "Chris Carter" <cdcarter@...> 2007/03/20

On 3/19/07, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:

[#10712] Ruby Method Signatures (was Re: Multiton in standard library) — "Rick DeNatale" <rick.denatale@...>

On 3/19/07, TRANS <transfire@gmail.com> wrote:

10 messages 2007/03/21
[#10715] Re: Ruby Method Signatures (was Re: Multiton in standard library) — Jos Backus <jos@...> 2007/03/22

On 3/19/07, TRANS <transfire@gmail.com> wrote:

[#10798] Virtual classes and 'real' classes -- why? — "John Lam (CLR)" <jflam@...>

I was wondering if someone could help me understand why there's a parallel =

12 messages 2007/03/28
[#10799] Re: Virtual classes and 'real' classes -- why? — MenTaLguY <mental@...> 2007/03/28

On Thu, 29 Mar 2007 04:44:16 +0900, "John Lam (CLR)" <jflam@microsoft.com> wrote:

Re: [PATCH] grave bug in 1.8.6's thread implementation

From: Sylvain Joyeux <sylvain.joyeux@...4x.org>
Date: 2007-03-15 12:08:03 UTC
List: ruby-core #10610
> Which set of patches do you think should be committed?  The former to
> ruby_1_8 and the latter to ruby_1_8_6?
The latter patches must be applied to 1.8.6, since for now 1.8.6 with 
the 'new' thread support is unusable for multi-threaded programs.

The former patches may not be applied at all. According to mental, it breaks 
compatibility (well, in my POV and mental's, it breaks poorly written 
programs ...). If you want to apply these changes, tell me so that I rewrite 
the patches, the changes I made are quite ugly ...

Moreover, you should add fastthread's test suite to ruby's own, and merge in 
it the tests I wrote for the particular issues fixed by these patches 
(test_thread.rb)

For the sake of simplicity, I join all the files in this mail. I slightly 
modified the test for ConditionVariable#wait in exception context, so please 
consider only the files in this mail.

Regards
Sylvain Joyeux

Attachments (5)

thread-condvar_wait.diff (1.09 KB, text/x-diff)
--- /home/sjoyeux/system/ruby-1.8.6/ext/thread/thread.c	2007-03-03 11:08:06.000000000 +0100
+++ thread.c	2007-03-14 17:39:31.000000000 +0100
@@ -391,7 +410,7 @@ rb_mutex_try_lock(VALUE self)
  *
  */
 
-static void
+static VALUE
 lock_mutex(Mutex *mutex)
 {
     VALUE current;
@@ -406,6 +425,7 @@ lock_mutex(Mutex *mutex)
     mutex->owner = current; 
 
     rb_thread_critical = 0;
+    return Qnil;
 }
 
 static VALUE
@@ -624,18 +645,12 @@ static void
 wait_condvar(ConditionVariable *condvar, Mutex *mutex)
 {
     rb_thread_critical = 1;
-    if (!RTEST(mutex->owner)) {
+    if (rb_thread_current() != mutex->owner) {
         rb_thread_critical = 0;
-        return;
+        rb_raise(rb_eThreadError, "not owner of the synchronization mutex");
     }
-    if (mutex->owner != rb_thread_current()) {
-        rb_thread_critical = 0;
-        rb_raise(rb_eThreadError, "Not owner");
-    }
-    mutex->owner = Qnil;
-    wait_list(&condvar->waiting);
-
-    lock_mutex(mutex);
+    unlock_mutex_inner(mutex);
+    rb_ensure(wait_list, (VALUE)&condvar->waiting, lock_mutex, (VALUE)mutex);
 }
 
 static VALUE
thread-mutex-not_owner.diff (492 Bytes, text/x-diff)
--- /home/sjoyeux/system/ruby-1.8.6/ext/thread/thread.c	2007-03-03 11:08:06.000000000 +0100
+++ thread.c	2007-03-14 15:36:58.000000000 +0100
@@ -429,8 +443,13 @@ unlock_mutex_inner(Mutex *mutex)
     VALUE waking;
 
     if (!RTEST(mutex->owner)) {
-        return Qundef;
+	rb_raise(rb_eThreadError, "not owner");
+    }
+
+    if (mutex->owner != rb_thread_current()) {
+	rb_raise(rb_eThreadError, "not owner");
     }
+
     mutex->owner = Qnil;
     waking = wake_one(&mutex->waiting);
 
thread-mutex-remove_one.diff (999 Bytes, text/x-diff)
--- /home/sjoyeux/system/ruby-1.8.6/ext/thread/thread.c	2007-03-03 11:08:06.000000000 +0100
+++ thread.c	2007-03-14 17:12:38.000000000 +0100
@@ -165,12 +165,23 @@ remove_one(List *list, VALUE value)
     Entry **ref;
     Entry *entry;
 
-    for (ref = &list->entries, entry = list->entries;
-              entry != NULL;
-              ref = &entry->next, entry = entry->next) {
-        if (entry->value == value) {
-            *ref = entry->next;
-            recycle_entries(list, entry, entry);
+    entry = list->entries;
+    if (!entry) return;
+    if (entry->value == value)
+    {
+	shift_list(list);
+	return;
+    }
+
+    for (entry = list->entries; entry->next != NULL; entry = entry->next) {
+	Entry* next_entry = entry->next;
+        if (next_entry->value == value) {
+	    entry->next = next_entry->next;
+	    if (!entry->next)
+		list->last_entry = entry;
+
+	    --list->size;
+            recycle_entries(list, next_entry, next_entry);
             break;
         }
     }
thread-mutex-recursive_lock.diff (419 Bytes, text/x-diff)
--- /home/sjoyeux/system/ruby-1.8.6/ext/thread/thread.c	2007-03-03 11:08:06.000000000 +0100
+++ thread.c	2007-03-14 15:45:24.000000000 +0100
@@ -399,6 +410,9 @@ lock_mutex(Mutex *mutex)
     rb_thread_critical = 1;
 
     while (RTEST(mutex->owner)) {
+	if (mutex->owner == current)
+	    rb_raise(rb_eThreadError, "recursive mutex lock");
+
         wait_list(&mutex->waiting);
         rb_thread_critical = 1;
     }
test_thread.rb (1.23 KB, application/x-ruby)

In This Thread