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

ThreadedNexter shutdown can in some situations interrupt a thread executing a different task #4887

Closed
wants to merge 1 commit into from

Conversation

@jmalves
Copy link
Contributor

@jmalves jmalves commented Dec 7, 2017

It can happen that the ThreadedNexter#shutdown from RubyEnumerator sends interrupts to a thread that is executing a different task.

ThreadedNexter#shutdown can get the thread value before the Nexter thread is finished but send the interrupts after the Nexter thread is already done with its work. In case that the Nexter thread is already assigned another task those interrupts can cause problems.

From what I could see it seems it affects all JRuby versions with ThreadedNexter.

To reproduce the issue:

threads = []

200.times do
  threads << Thread.new do
    enumerable1 = (1..1000)
    enumerable2 = (1..1000)
    100.times do
      enumerable1.zip(enumerable2).map { |(a, b)| a^b }
    end
  end
end

threads.each(&:join)

Related to #2577 and #2824

@headius
Copy link
Member

@headius headius commented Dec 12, 2017

Very nice find! There have been lingering intermittent interrupted threads reported occasionally...this could have been the culprit.

I'll have a look.

@headius
Copy link
Member

@headius headius commented Dec 12, 2017

It looks good, but I will merge manually to the 9.1 branch so it can be in 9.1.16.

@headius headius added this to the JRuby 9.1.16.0 milestone Dec 12, 2017
@headius
Copy link
Member

@headius headius commented Dec 12, 2017

Merged to 9.1 in 3011d3d.

@headius headius closed this Dec 12, 2017
@headius
Copy link
Member

@headius headius commented Dec 12, 2017

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.