Skip to content

Thread.current.status is wrong for killed thread #4705

@iaddict

Description

@iaddict

Environment

Provide at least:

  • JRuby version: 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 [darwin-x86_64]
  • Operating system and platform: Darwin de01pc11303.global.jhcn.net 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64

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'.

t = Thread.new {
  begin
    sleep
  ensure
    puts Thread.current.status # should output 'aborting' when killed
  end
}
t.kill

Example run on jruby:

irb(main):020:0> t = Thread.new { begin; sleep; ensure; puts Thread.current.status; end }
=> #<Thread:0x79ad8b2f@(irb):20 sleep>
irb(main):021:0> t.kill
run
=> #<Thread:0x79ad8b2f@(irb):20 dead>

Example run on mri ruby:

irb(main):013:0>  t = Thread.new { begin; sleep; ensure; puts Thread.current.status; end }
=> #<Thread:0x007faefc8bad78@(irb):13 run>
irb(main):014:0> t.kill
aborting
=> #<Thread:0x007faefc8bad78@(irb):13 sleep>

This code is a simplified version of ActiveRecord transaction code that fails.
See:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions