From: "kosaki (Motohiro KOSAKI)" <kosaki.motohiro@gmail•com>
To: ruby-dev@ruby-lang.org (ruby developers list)
Subject: [ruby-dev:46638] [ruby-trunk - Bug #5368] ensure節でsleepするようなThreadがあるとインタプリタが終了しない
Date: Tue, 27 Nov 2012 08:16:23 +0900 [thread overview]
Message-ID: <redmine.journal-33990.20121127081619@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-5368.20110926135100@ruby-lang.org
Issue #5368 has been updated by kosaki (Motohiro KOSAKI).
1.8と同等と書いたのは
Thread.new do
begin
sleep
ensure
sleep
end
end
というプログラムが一度ensure節のsleepで寝てしまうが、Ctrl-Cにより終わることは出来る。という挙動を指しており、
このスクリプト以外の細かい挙動について、不整合はあると思います。
----------------------------------------
Bug #5368: ensure節でsleepするようなThreadがあるとインタプリタが終了しない
https://bugs.ruby-lang.org/issues/5368#change-33990
Author: Glass_saga (Masaki Matsushita)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: 2.0.0
ruby -v: -
=begin
次のコードを実行するとCPU使用率が跳ね上がった状態になりインタプリタが終了しません。
Thread.new do
begin
sleep
ensure
sleep
end
end
現在のrb_thread_terminate_allでは最初に1回だけ生きているスレッドに対してterminate_iを実行していますが、ensure節でsleepするようなThreadがあると、そのThreadは寝たままになってしまいwhile(!rb_thread_alone())が無限ループになってしまいます。
while(!rb_thread_alone())の毎回のループでカレントスレッドがメインスレッドであった場合に、生きているスレッドに対してterminate_iを実行するようなpatchを書いたところ、このバグは再現しなくなりました。
patchを添付します。patchの適用後もtest-allをパスします。
=end
--
http://bugs.ruby-lang.org/
next prev parent reply other threads:[~2012-11-26 23:18 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-26 4:51 [ruby-dev:44546] [Ruby 1.9 - Bug #5368][Open] ensure節でsleepするようなThreadがあるとインタプリタが終了しない Masaki Matsushita
2011-09-26 5:24 ` [ruby-dev:44547] " SASADA Koichi
2011-09-26 13:40 ` [ruby-dev:44550] " KOSAKI Motohiro
2011-09-26 14:03 ` [ruby-dev:44551] " m_takao
2011-09-26 14:52 ` [ruby-dev:44552] " SASADA Koichi
2011-09-29 11:20 ` [ruby-dev:44561] " Nobuyoshi Nakada
2011-09-29 12:14 ` [ruby-dev:44563] " KOSAKI Motohiro
2011-09-29 16:29 ` [ruby-dev:44564] [Ruby 1.9 - Bug #5368] ensure節でsleepするようなThreadがあるとインタプリタが終了しない Shyouhei Urabe
2012-03-11 7:06 ` [ruby-dev:45327] [ruby-trunk " Koichi Sasada
2012-11-26 0:26 ` [ruby-dev:46622] " ko1 (Koichi Sasada)
2012-11-26 3:27 ` [ruby-dev:46626] " kosaki (Motohiro KOSAKI)
2012-11-26 13:40 ` [ruby-dev:46631] " kosaki (Motohiro KOSAKI)
2012-11-26 13:59 ` [ruby-dev:46632] [ruby-trunk - Bug #5368][Assigned] ensure節でsleepするようなThreadがあるとインタプリタが終了しない kosaki (Motohiro KOSAKI)
2012-11-26 16:15 ` [ruby-dev:46634] [ruby-trunk - Bug #5368] ensure節でsleepするようなThreadがあるとインタプリタが終了しない kosaki (Motohiro KOSAKI)
2012-11-26 16:26 ` [ruby-dev:46635] " kosaki (Motohiro KOSAKI)
2012-11-26 20:09 ` [ruby-dev:46636] " tarui (Masaya Tarui)
2012-11-26 23:13 ` [ruby-dev:46637] " kosaki (Motohiro KOSAKI)
2012-11-26 23:16 ` kosaki (Motohiro KOSAKI) [this message]
2012-11-27 17:08 ` [ruby-dev:46643] " kosaki (Motohiro KOSAKI)
2013-02-17 6:19 ` [ruby-dev:47006] " ko1 (Koichi Sasada)
2014-01-30 6:16 ` [ruby-dev:47929] " shibata.hiroshi
2018-04-06 5:28 ` [ruby-dev:50521] [Ruby trunk Bug#5368] ensure節でsleepするようなThreadがあるとインタプリタが終了しない mame
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-33990.20121127081619@ruby-lang.org \
--to=ruby-dev@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).