Skip to content

Kernel#sleep hangs on CI #5365

@ahorek

Description

@ahorek

Environment

jruby 9.2.1.0-SNAPSHOT (2.5.0) 2018-10-12 b2f694c Java HotSpot(TM) 64-Bit Server VM 25.181-b13 on 1.8.0_181-b13 +jit [linux-x86_64]

script

100.times do
  t = Thread.new do
    Kernel.sleep
    :ok
  end

  JRuby.reference(t).native_thread.interrupt
  t.value
end

JRuby.reference(t).native_thread.interrupt should stop the thread

  t = Thread.new do
    Kernel.sleep
    :ok
  end

  JRuby.reference(t).native_thread.interrupt
  => #<Thread:0x69aabcb0@(irb):31 dead>

under load (if I run it in a loop), some threads sometimes remain still in a sleep state

=> #<Thread:0x2dfeb141@(irb):39 sleep>

t.value calls Thread#join and because the thread is alive, it sleeps forever

if (!threadImpl.isAlive()) {

Expected Behavior

it looks like there's a race condition somewhere? If I add a sleep call between Thread.new and thread.interrupt it won't hang. Or is it just a bad test?

100.times do
  t = Thread.new do
    Kernel.sleep
    :ok
  end

  sleep 0.25
  JRuby.reference(t).native_thread.interrupt
  t.value
end

Actual Behavior

hangs in an infinite loop

https://travis-ci.org/jruby/jruby/jobs/440880330

....
     [exec] Kernel#sleep
No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.
Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received
The build has been terminated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions