Project

General

Profile

Actions

Backport #8065

closed

r39688 - test_queue.rb (test_thr_kill): reduce iterations from 2000 to 250. のバックポート

Added by kosaki (Motohiro KOSAKI) over 11 years ago. Updated over 11 years ago.


Description

現在、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] の原因だと見ています。確証はないので、別チケットにしましたが。


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #7521: test_thr_kill(TestQueue) failsClosedkosaki (Motohiro KOSAKI)12/06/2012Actions
Actions #1

Updated by nagachika (Tomoyuki Chikanaga) over 11 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r39728.
Motohiro, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 39688: [Backport #8065]

* test/thread/test_queue.rb (TestQueue#test_thr_kill): reduce
  iterations from 2000 to 250. When running on uniprocessor
  systems, every th.kill needs TIME_QUANTUM_USEC time (i.e.
  100msec on posix systems). Because, "r.read 1" is 3 steps
  operations that 1) release GVL 2) read 3) acquire gvl and
  (1) invoke context switch to main thread. and then, main
  thread's th.kill resume (1), but not (2). Thus read interrupt
  need TIME_QUANTUM_USEC. Then maximum iteration is 30sec/100msec
  = 300.
Actions

Also available in: Atom PDF

Like0
Like0