Skip to content
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#status can return unexpected value "dead" #5377

Closed
mperham opened this Issue Oct 19, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@mperham
Copy link

commented Oct 19, 2018

This Sidekiq build is failing due to a spec that expects a thread to be dead and therefore Thread#status to return false.

https://travis-ci.org/mperham/sidekiq/jobs/443494780

The Thread#status return values are documented here and "dead" is not one of them:

https://ruby-doc.org/core-2.3.0/Thread.html#method-i-status

I can't reproduce this locally, the specs pass for me on 9.1.6.0, 9.1.17.0, and 9.2.0.0.

@headius

This comment has been minimized.

Copy link
Member

commented Oct 19, 2018

I believe this has come up one or twice. I believe the issue is that this "dead" status was either something from CRuby versions before 1.9, or it's a status we added to indicate that a thread was about to terminate but had not yet terminated (in MRI there's no difference between most of these states since a Thread can't context-switch when it's at the end of dying).

So it's a bit of a debate whether this should be a valid status, but the race here is that the thread is still in the process of terminating when you see this "dead" status. I'll have another look at getting rid of this.

@headius

This comment has been minimized.

Copy link
Member

commented Oct 19, 2018

I can make the "dead" less likely or impossible to show up by checking it as well as thread "liveliness" when presenting Thread#status. So when we're in that short period after the thread has cleaned up all its locks and resources but before the native thread stops, it will still show up as "nil" status.

headius added a commit that referenced this issue Oct 19, 2018

Always treat "dead" status as truly dead and return nil.
Relates to #5377 and some other "dead" status bugs.

@headius headius added this to the JRuby 9.2.1.0 milestone Oct 19, 2018

@headius headius closed this Oct 19, 2018

@headius

This comment has been minimized.

Copy link
Member

commented Oct 19, 2018

Difficult to test, but it should be fixed in bf80054. @mperham hopefully you can get a "head" build of JRuby to test against, but otherwise let us know if you see issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.