Forum: Ruby-dev [Backport 200 - Backport #8065][Assigned] r39688 - test queue.rb (test thr kill): reduce iterations

Posted by kosaki (Motohiro KOSAKI) (Guest)
on 2013-03-10 05:46
(Received via mailing list)
Issue #8065 has been reported by kosaki (Motohiro KOSAKI).

----------------------------------------
Backport #8065: r39688 - test_queue.rb (test_thr_kill): reduce 
iterations from 2000 to 250. のバックポート
https://bugs.ruby-lang.org/issues/8065

Author: kosaki (Motohiro KOSAKI)
Status: Assigned
Priority: Normal
Assignee: nagachika (Tomoyuki Chikanaga)
Category:
Target version:


現在、uniprocessor環境で test_thr_killを実行すると、ほぼ必ず失敗します。原因はコミットログにも書いたのですが
以下の様なスクリプトがあるとき、

total_count.times do |i|
  open("test_thr_kill_count", "w") {|f| f.puts i }
  queue = Queue.new
  r, w = IO.pipe
  th = Thread.start {
    queue.push(nil)
    r.read 1
  }
  queue.pop
  th.kill
  th.join
end

ほぼ確実に、

1、Thread.start
2.Queue.pop
3,ここでコンテキストスイッチ
4,Queue.push
5.r.readの処理の途中で gvl_release()
6.ここでコンテキストスイッチ
7.th.kill -> ubf_select -> pthread_kill(SIGVTALARM) とくるが、
      別に、ブロッキングシステムコールで寝ているわけではないので
      サブスレッドには影響ない
8.th.join
9.ここでコンテキストスイッチ
10.read(2) を呼ぶ
11.ここで動いているスレッドが一旦いなくなる
12.100msec後にtimer threadがSIGVTALARMを再送、read()が解除される

と動くので、30秒間では300回しかループが回りません。

状況証拠的に [Bug #7521] の原因だと見ています。確証はないので、別チケットにしましたが。
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.