Project

General

Profile

Bug #5993 » thread_exit_in_fiber.patch

nagachika (Tomoyuki Chikanaga), 12/19/2012 02:31 AM

View differences:

cont.c
1172 1172
	if (state == TAG_RAISE) {
1173 1173
	    rb_threadptr_async_errinfo_enque(th, th->errinfo);
1174 1174
	}
1175
	else if (state == TAG_FATAL) {
1176
	    rb_threadptr_async_errinfo_enque(th, th->errinfo);
1177
	}
1175 1178
	else {
1176 1179
	    VALUE err = rb_vm_make_jump_tag_but_local_jump(state, th->errinfo);
1177 1180
	    if (!NIL_P(err))
test/ruby/test_fiber.rb
266 266
  def test_exit_in_fiber
267 267
    bug5993 = '[ruby-dev:45218]'
268 268
    assert_nothing_raised(bug5993) do
269
      Thread.new{ Fiber.new{ Thread.exit }.resume }.join
269
      Thread.new{ Fiber.new{ Thread.exit }.resume; raise "unreachable" }.join
270 270
    end
271 271
  end
272 272

  
thread.c
1836 1836
	    if (err == Qundef) {
1837 1837
		/* no error */
1838 1838
	    }
1839
	    else if (err == eKillSignal      /* Thread#kill receieved */  ||
1840
		     err == eTerminateSignal /* Terminate thread */ ) {
1839
	    else if (err == eKillSignal        /* Thread#kill receieved */  ||
1840
		     err == eTerminateSignal   /* Terminate thread */       ||
1841
		     err == INT2FIX(TAG_FATAL) /* Thread.exit etc. */         ) {
1841 1842
		rb_threadptr_to_kill(th);
1842 1843
	    }
1843 1844
	    else {
vm.c
917 917
      case TAG_RETRY:
918 918
	result = make_localjump_error("retry outside of rescue clause", Qnil, state);
919 919
	break;
920
      case TAG_FATAL:
921
	/* internal exception or Thread.exit */
922
	/* Thread.exit set th->errinfo to INT2FIX(TAG_FATAL) */
923
	if (!FIXNUM_P(val))
924
	    result = val;
925 920
      default:
926 921
	break;
927 922
    }