thread.c: deadlock in backtrace

* thread.c (unblock_function_set): check interrupts just once
  during raising exceptions, as they are deferred since r16651.
  [ruby-core:85939] [Bug #14577]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-03-06 05:15:57 +00:00
Родитель e667897b46
Коммит ec826b3f93
2 изменённых файлов: 23 добавлений и 1 удалений

Просмотреть файл

@ -1200,6 +1200,28 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
end;
end
def test_blocking_backtrace
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
class Bug < RuntimeError
def backtrace
IO.readlines(IO::NULL)
end
end
bug = Bug.new '[ruby-core:85939] [Bug #14577]'
n = 10000
i = 0
n.times do
begin
raise bug
rescue Bug
i += 1
end
end
assert_equal(n, i)
end;
end
def test_wrong_backtrace
assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}")
begin;

Просмотреть файл

@ -428,7 +428,7 @@ unblock_function_set(rb_thread_t *th, rb_unblock_function_t *func, void *arg, in
}
rb_native_mutex_lock(&th->interrupt_lock);
} while (RUBY_VM_INTERRUPTED_ANY(th->ec) &&
} while (!th->ec->raised_flag && RUBY_VM_INTERRUPTED_ANY(th->ec) &&
(rb_native_mutex_unlock(&th->interrupt_lock), TRUE));
VM_ASSERT(th->unblock.func == NULL);