[MacRuby] #1076: Abort occurs when raise a SecurityError within Thread.

MacRuby ruby-noreply at macosforge.org
Tue Jan 25 15:06:49 PST 2011


#1076: Abort occurs when raise a SecurityError within Thread.
----------------------------------+-----------------------------------------
 Reporter:  watson1978@…          |       Owner:  lsansonetti@…        
     Type:  defect                |      Status:  new                  
 Priority:  blocker               |   Milestone:                       
Component:  MacRuby               |    Keywords:                       
----------------------------------+-----------------------------------------

Comment(by watson1978@…):

 I think that should not raise an exception in
 rb_thread_remove_from_group().
 Because the exception of rb_thread_remove_from_group() is not caught
 within rb_vm_thread_run().

 Patch:
 {{{
 #!diff
 diff --git a/NSArray.m b/NSArray.m
 index 8916881..b1c714e 100644
 --- a/NSArray.m
 +++ b/NSArray.m
 @@ -1280,6 +1280,17 @@ rb_ary_delete(VALUE ary, VALUE item)
  }

  VALUE
 +rb_ary_delete_force(VALUE ary, VALUE item)
 +{
 +    if (IS_RARY(ary)) {
 +       return rary_delete_force(ary, 0, item);
 +    }
 +    else {
 +       return nsary_delete((id)ary, 0, item);
 +    }
 +}
 +
 +VALUE
  rb_ary_delete_at(VALUE ary, long pos)
  {
      if (IS_RARY(ary)) {
 diff --git a/array.c b/array.c
 index 2c1c486..2cd818c 100644
 --- a/array.c
 +++ b/array.c
 @@ -1854,6 +1854,15 @@ rary_delete(VALUE ary, SEL sel, VALUE item)
      return item;
  }

 +VALUE
 +rary_delete_force(VALUE ary, SEL sel, VALUE item)
 +{
 +    if (rary_delete_element(ary, item, true) == false) {
 +       return Qnil;
 +    }
 +    return item;
 +}
 +
  /*
   *  call-seq:
   *     array.delete_at(index)  -> obj or nil
 diff --git a/array.h b/array.h
 index 4f44716..fb4419a 100644
 --- a/array.h
 +++ b/array.h
 @@ -146,6 +146,7 @@ VALUE rary_clear(VALUE ary, SEL sel);
  VALUE rary_reverse_bang(VALUE ary, SEL sel);
  VALUE rary_includes(VALUE ary, SEL sel, VALUE item);
  VALUE rary_delete(VALUE ary, SEL sel, VALUE item);
 +VALUE rary_delete_force(VALUE ary, SEL sel, VALUE item);
  VALUE rary_delete_at(VALUE ary, SEL sel, VALUE pos);
  VALUE rary_pop(VALUE ary, SEL sel, int argc, VALUE *argv);
  VALUE rary_shift(VALUE ary, SEL sel, int argc, VALUE *argv);
 diff --git a/macruby_internal.h b/macruby_internal.h
 index 53fad7b..484e857 100644
 --- a/macruby_internal.h
 +++ b/macruby_internal.h
 @@ -103,6 +103,8 @@ VALUE rb_io_addstr(VALUE, SEL, VALUE);
  VALUE rb_io_printf(VALUE, SEL, int, VALUE *);
  VALUE rb_io_print(VALUE, SEL, int, VALUE *);

 +VALUE rb_ary_delete_force(VALUE ary, VALUE item);
 +
  VALUE rb_objc_num_coerce_bin(VALUE x, VALUE Y, SEL sel);
  VALUE rb_objc_num_coerce_cmp(VALUE, VALUE, SEL sel);
  VALUE rb_objc_num_coerce_relop(VALUE, VALUE, SEL sel);
 diff --git a/thread.c b/thread.c
 index 5c6296b..476c642 100644
 --- a/thread.c
 +++ b/thread.c
 @@ -1329,7 +1329,7 @@ rb_thread_remove_from_group(VALUE thread)
      if (t->group != Qnil) {
         rb_thread_group_t *tg = GetThreadGroupPtr(t->group);
         thgroup_lock(tg);
 -       if (rb_ary_delete(tg->threads, thread) != thread) {
 +       if (rb_ary_delete_force(tg->threads, thread) != thread) {
             printf("trying to remove a thread (%p) from a group that
 doesn't "\
                     "contain it\n", (void *)thread);
             abort();
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/1076#comment:1>
MacRuby <http://macruby.org/>



More information about the macruby-tickets mailing list