Project

General

Profile

Bug #7460 » terminate_all-deadlock-check.patch

kosaki (Motohiro KOSAKI), 11/29/2012 10:02 AM

View differences:

eval.c
185 185
    if ((state = EXEC_TAG()) == 0) {
186 186
	SAVE_ROOT_JMPBUF(th, rb_thread_terminate_all());
187 187
    }
188
    else if (ex == 0) {
189
	ex = state;
188
    else {
189
	if (state == TAG_FATAL) {
190
	    ex = state;
191
	    errs[1] = th->errinfo;
192
	} else if (ex == 0) {
193
	    ex = state;
194
	}
190 195
    }
191 196
    th->errinfo = errs[1];
192 197
    ex = error_handle(ex);
thread.c
389 389

  
390 390
	TH_PUSH_TAG(th);
391 391
	if ((state = TH_EXEC_TAG()) == 0) {
392
	    GET_VM()->sleeper++;
392 393
	    native_sleep(th, 0);
394
	    GET_VM()->sleeper--;
393 395
	    RUBY_VM_CHECK_INTS_BLOCKING(th);
394 396
	}
395 397
	TH_POP_TAG();
396 398

  
397
	if (state) {
399
	if (state == TAG_FATAL) {
400
	    JUMP_TAG(state);
401
	}
402
	else if (state) {
398 403
	    goto retry;
399 404
	}
400 405
    }
......
1789 1794
		if (th->status == THREAD_STOPPED ||
1790 1795
		    th->status == THREAD_STOPPED_FOREVER)
1791 1796
		    th->status = THREAD_RUNNABLE;
1792
		rb_exc_raise(err);
1797
		if (rb_obj_is_kind_of(err, rb_eFatal))
1798
		    rb_exc_fatal(err);
1799
		else
1800
		    rb_exc_raise(err);
1793 1801
	    }
1794 1802
	}
1795 1803

  
......
1833 1841
rb_threadptr_raise(rb_thread_t *th, int argc, VALUE *argv)
1834 1842
{
1835 1843
    VALUE exc;
1844
    int fatal = 0;
1836 1845

  
1837
    if (rb_threadptr_dead(th)) {
1846
    if (argc >= 1 && argv[0] == rb_eFatal)
1847
	fatal = 1;
1848

  
1849
    if (!fatal && rb_threadptr_dead(th)) {
1838 1850
	return Qnil;
1839 1851
    }
1840 1852

  
......
4869 4881
    rb_thread_t *th;
4870 4882
    GetThreadPtr(thval, th);
4871 4883

  
4872
    if (th->status != THREAD_STOPPED_FOREVER || RUBY_VM_INTERRUPTED(th)) {
4884
    if ((th->status & (THREAD_RUNNABLE|THREAD_STOPPED)) ||
4885
	RUBY_VM_INTERRUPTED(th)) {
4873 4886
	*found = 1;
4874 4887
    }
4875 4888
    else if (th->locking_mutex) {
vm_core.h
425 425
    TypedData_Get_Struct((obj), rb_thread_t, &ruby_threadptr_data_type, (ptr))
426 426

  
427 427
enum rb_thread_status {
428
    THREAD_RUNNABLE,
429
    THREAD_STOPPED,
430
    THREAD_STOPPED_FOREVER,
431
    THREAD_KILLED
428
    THREAD_RUNNABLE	   = 0x1,
429
    THREAD_STOPPED	   = 0x2,
430
    THREAD_STOPPED_FOREVER = 0x4,
431
    THREAD_KILLED	   = 0x8,
432 432
};
433 433

  
434 434
typedef RUBY_JMP_BUF rb_jmpbuf_t;