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

test_status_and_stop_p exposes a race in Thread status #5312

Closed
headius opened this Issue Sep 18, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@headius
Copy link
Member

headius commented Sep 18, 2018

The test test_status_and_stop_p in at test/mri/ruby/test_thread.rb:460 attempts a complicated set of thread status checks. One of these checks, specifically the assert_equal(nil, a.status) seem to expose a race in the death of a thread on JRuby.

The logic reached at this point asserts that #status shall be nil for a thread that returns false for #alive?. However in JRuby, before the Thread has completed dying and the status is cleared, the status is "dead". Occasionally this test executes quickly enough to see that the thread has started dying but not yet completed.

The "dead" status needs to be audited and compared with MRI behaviors, since it may be acceptable to clear the status immediately once the thread is assuredly on its way to dying.

I will mask out the test for now.

@headius

This comment has been minimized.

Copy link
Member Author

headius commented Sep 18, 2018

headius added a commit that referenced this issue Sep 18, 2018

Mask out this test temporarily for #5312.
This is either a race we can fix, a fixable behavioral difference
with MRI, or an unfixable difference in how thread status works
under parallel thread execution.
@headius

This comment has been minimized.

Copy link
Member Author

headius commented Sep 18, 2018

This might be fixable by having #status wait for the thread to finish dying when the status is "dead". There's a good chance this process could lead to deadlocks if a thread attempts to work with locks on its way to death.

kares added a commit to kares/jruby that referenced this issue Jan 2, 2019

[fix] Thread#status should reflect exited exception
a non-alive thread should check existing exception

backing Java thread might still be 'alive' after its disposed
(see RubyRunnable) such state shall not avoid the exception check
since the RubyThread is already effective dead (unregistered etc)

resolves jrubyGH-5312
this can alternatively be accomplished using the disposed flag

@kares kares self-assigned this Jan 2, 2019

kares added a commit to kares/jruby that referenced this issue Jan 11, 2019

[fix] Thread#status should reflect exited exception
a non-alive thread should check existing exception

backing Java thread might still be 'alive' after its disposed
(see RubyRunnable) such state shall not avoid the exception check
since the RubyThread is already effective dead (unregistered etc)

resolves jrubyGH-5312
this can alternatively be accomplished using the disposed flag

@kares kares closed this in #5554 Jan 21, 2019

@kares kares added this to the JRuby 9.2.6.0 milestone Jan 21, 2019

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.