check thread deadness correctly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
92b710e64b
commit
38bc085f71
@ -1160,4 +1160,14 @@ q.pop
|
|||||||
c = Class.new(Thread) {def initialize() self.name = "foo"; super; end}
|
c = Class.new(Thread) {def initialize() self.name = "foo"; super; end}
|
||||||
assert_equal("foo", c.new {Thread.current.name}.value, bug12290)
|
assert_equal("foo", c.new {Thread.current.name}.value, bug12290)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_thread_interrupt_for_killed_thread
|
||||||
|
assert_normal_exit(<<-_end, '[Bug #8996]', timeout: 5, timeout_error: nil)
|
||||||
|
trap(:TERM){exit}
|
||||||
|
while true
|
||||||
|
t = Thread.new{sleep 0}
|
||||||
|
t.raise Interrupt
|
||||||
|
end
|
||||||
|
_end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
7
thread.c
7
thread.c
@ -2107,6 +2107,13 @@ rb_threadptr_raise(rb_thread_t *th, int argc, VALUE *argv)
|
|||||||
else {
|
else {
|
||||||
exc = rb_make_exception(argc, argv);
|
exc = rb_make_exception(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* making an exception object can switch thread,
|
||||||
|
so we need to check thread deadness again */
|
||||||
|
if (rb_threadptr_dead(th)) {
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
rb_threadptr_setup_exception(GET_THREAD(), exc, Qundef);
|
rb_threadptr_setup_exception(GET_THREAD(), exc, Qundef);
|
||||||
rb_threadptr_pending_interrupt_enque(th, exc);
|
rb_threadptr_pending_interrupt_enque(th, exc);
|
||||||
rb_threadptr_interrupt(th);
|
rb_threadptr_interrupt(th);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user