summaryrefslogtreecommitdiff
path: root/test/ruby/test_thread.rb
diff options
context:
space:
mode:
authorLuke Gruber <luke.gruber@shopify.com>2026-01-27 12:36:55 -0500
committerGitHub <noreply@github.com>2026-01-27 12:36:55 -0500
commit52e71ad4b766d57236e66ebbc419a4447fb0b491 (patch)
tree22d1544e7ddc3018f3682d1a198a34dc81045c01 /test/ruby/test_thread.rb
parent5d769228c1055524205437860beb1fc2de2d11a0 (diff)
Fix test for mutex starvation as well as small fix in thread_sync.c (#15982)
Don't reset `th->running_time_us` when unlocking from `mutex_free` or force unlocking during thread destruction. Follow-up to 994257ab06072d.
Diffstat (limited to 'test/ruby/test_thread.rb')
-rw-r--r--test/ruby/test_thread.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index 60e3aa772a..47a8e94c07 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -1667,22 +1667,24 @@ q.pop
# [Bug #21840]
def test_mutex_owner_doesnt_starve_waiters
- assert_ruby_status([], "#{<<~"begin;"}\n#{<<~'end;'}")
+ assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
+ require "tempfile"
+ temp = Tempfile.new("temp")
m = Mutex.new
- fib = lambda { |n|
+ def fib(n)
return n if n <= 1
fib(n - 1) + fib(n - 2)
- }
+ end
t1_running = false
- t1 = Thread.new do
+ Thread.new do
t1_running = true
loop do
fib(20)
m.synchronize do
- File.open(__FILE__) { } # reset timeslice due to blocking operation
+ File.open(temp.path) { } # reset timeslice due to blocking operation
end
end
end