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

Fix spec of Thread#status for an externally killed thread that sleeps #4815

Merged
merged 1 commit into from Oct 12, 2017

Conversation

Projects
None yet
4 participants
@iaddict
Contributor

iaddict commented Oct 12, 2017

Fixes #4705

@enebo

On the face of this I think this seems reasonable but I think @headius should also review this since it is threading and threading is hard :)

@headius

This comment has been minimized.

Member

headius commented Oct 12, 2017

There could be a race here, if a thread marks itself as aborting and then some other thread tries to exit sleep at the same time, but ideally exitSleep should only be called by that thread when it transitions. The uses I reviewed seem to fit that pattern.

Worst case, some bad actor might cause an aborting thread to mark itself as runnable again. it would be no worse than now but less likely to happen.

@headius headius merged commit 6dd82b3 into jruby:master Oct 12, 2017

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Details

@headius headius added this to the JRuby 9.2.0.0 milestone Oct 12, 2017

@eregon

This comment has been minimized.

Member

eregon commented Oct 12, 2017

FWIW The way we do in in TruffleRuby is to save/restore the Thread status around sleep/blocking tasks.
And since only the current thread modifies its status and we poll for interrupts after restoring the thread state when interrupted in a blocking task, I believe this is safe and race-free.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment