summaryrefslogtreecommitdiff
path: root/test/ruby/test_sleep.rb
AgeCommit message (Collapse)Author
10 daysFix sleep spurious wakeup from sigchld (#15802)Luke Gruber
When sleeping with `sleep`, currently the main thread can get woken up from sigchld from any thread (subprocess exited). The timer thread wakes up the main thread when this happens, as it checks for signals. The main thread then executes the ruby sigchld handler if one is registered and is supposed to go back to sleep immediately. This is not ideal but it's the way it's worked for a while. In commit 8d8159e7d8 I added writes to `th->status` before and after `wait_running_turn` in `thread_sched_to_waiting_until_wakeup`, which is called from `sleep`. This is usually the right way to set the thread's status, but `sleep` is an exception because the writes to `th->status` are done in `sleep_forever`. There's a loop that checks `th->status` in `sleep_forever`. When the main thread got woken up from sigchld it saw the changed `th->status` and continued to run the main thread instead of going back to sleep. The following script shows the error. It was returning instead of sleeping forever. ```ruby t = Thread.new do sleep 0.3 `echo hello` # Spawns subprocess puts "Subprocess exited" end puts "Main thread sleeping..." result = sleep # Should block forever puts "sleep returned: #{result.inspect}" ``` Fixes [Bug #21812]
2024-09-17Replace all GC.disable with EnvUtil.without_gcPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11635
2015-12-16Add frozen_string_literal: false for all filesnaruse
When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-22I suspect such early wakeup is because of automatic time correctionnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-18Use Etc.uname instead of uname command invocation.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-24call to_inaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-06test_sleep.rb: get rid of failure on Windowsnobu
* test/ruby/test_sleep.rb (test_sleep_5sec): relax bottom on Windows. assert_operator should test on the receiver. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-24Cent OS 5.6 wakes up in 4.989596sec from sleep(5).naruse
http://c5632.rubyci.org/~chkbuild/ruby-trunk/log/20120424T070102Z.log.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-06Fix typo.naruse
reported by Nobuhiro IMAI.$ https://twitter.com/no6v/status/176959588531314688 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-05* test/ruby/test_sleep.rb (TestSleep#test_sleep_5sec): syntax error.usa
* test/ruby/test_sleep.rb (TestSleep#test_sleep_5sec): call uname only on linux because it's a workaround for linux only. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-05Fix condition of r34897.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-05Old linux (at least CentOS 5.6, kernel 2.6.18) wakes up 4.99 sec.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-15* test/ruby/test_sleep.rb (test_sleep_5sec): 0.1sec tolerance is tooakr
small for busy environment. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-02* test/ruby/test_sleep.rb (test_sleep_5sec): stop gc.mame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-30* win32/win32.c (rb_w32_select): recalc the rest of timeout for eachnobu
iterations. [ruby-core:18015] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e