-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thread.current.status is wrong for killed thread #4705
Comments
did not expect using |
Interesting, I recently looked at this in TruffleRuby and could not figure how the user can observe the |
Here is a slightly better version of the sample code which uses a Queue to make sure that the thread is sleeping. q = Queue.new
t = Thread.new { begin; q.push nil; sleep; ensure; puts Thread.current.status; end }
q.pop
t.kill |
The status of a dying running or sleeping thread should be 'aborting'. On jruby this is not the case. These spec additions show this issue. There already is an open issue for jruby: jruby/jruby#4705 ``` $ ruby ./jruby/mspec/bin/mspec-run core/thread/stop_spec.rb jruby 9.1.12.0 (2.3.3) 2017-06-15 33c6439 Java HotSpot(TM) 64-Bit Server VM 25.112-b16 on 1.8.0_112-b16 +jit [darwin-x86_64] 1) Thread#status describes a dying running thread FAILED Expected "run" to equal "aborting" ./jruby/ruby-spec/core/thread/stop_spec.rb:60:in `block in (root)' org/jruby/RubyBasicObject.java:1691:in `instance_eval' org/jruby/RubyEnumerable.java:1596:in `all?' org/jruby/RubyFixnum.java:299:in `times' org/jruby/RubyArray.java:1734:in `each' ./jruby/ruby-spec/core/thread/stop_spec.rb:58:in `<main>' org/jruby/RubyKernel.java:979:in `load' org/jruby/RubyBasicObject.java:1691:in `instance_eval' org/jruby/RubyArray.java:1734:in `each' 2) Thread#status describes a dying sleeping thread FAILED Expected "run" to equal "aborting" ./jruby/ruby-spec/core/thread/stop_spec.rb:64:in `block in (root)' org/jruby/RubyBasicObject.java:1691:in `instance_eval' org/jruby/RubyEnumerable.java:1596:in `all?' org/jruby/RubyFixnum.java:299:in `times' org/jruby/RubyArray.java:1734:in `each' ./jruby/ruby-spec/core/thread/stop_spec.rb:58:in `<main>' org/jruby/RubyKernel.java:979:in `load' org/jruby/RubyBasicObject.java:1691:in `instance_eval' org/jruby/RubyArray.java:1734:in `each' [| | ==================100%================== | 00:00:00] 2F 0E Finished in 0.175762 seconds 1 file, 12 examples, 13 expectations, 2 failures, 0 errors, 0 tagged ```
I ran the specs again with the current jruby master branch and they did pass, albeit the above referenced pull request did not catch the issue in its entirety. I created another pull request that properly tests the status of a sleeping killed thread that fails on jruby but passes on mri. See: ruby/spec#462. Thus the problem is still present. |
That spec is now in jruby and fails as expected:
|
This is still a bug. I tagged the spec so the CI is green in 73b0114 |
@eregon Does this mean the bug does not get fixed anytime soon? The AR and transactions (mentioned above) will thus persist? |
I'm not fixing the bug in JRuby, merely updating the specs. |
Additional commit for this, to actually set aborting status upon kill: 919832e |
Environment
Provide at least:
Expected Behavior
A sleeping thread that gets killed should have status 'aborting' and not 'run'.
Actual Behavior
The following code outputs 'run' on jruby, whereas on mri it outputs 'aborting'.
Example run on jruby:
Example run on mri ruby:
This code is a simplified version of ActiveRecord transaction code that fails.
See:
The text was updated successfully, but these errors were encountered: