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

[Core] Fix race condition in Timeout #1244

Merged
merged 1 commit into from
Oct 13, 2017

Conversation

mpkorstanje
Copy link
Contributor

Summary

We need to ensure a happens before relation exists between these events;
a. the timer setting the interrupt flag on the execution thread.
b. terminating and cleaning up the timer
To do this we synchronize on monitor. The atomic boolean is merely a
convenient container.

Additionally Timeout did not throw any exceptions when the callback
was busy waiting but did set the interrupted flag. To resolve this
we check and throw after the completion of the callback.

This fixes #1241

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist:

  • I've added tests for my code.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

We need to ensure a happens before relation exists between these events;
  a. the timer setting the interrupt flag on the execution thread.
  b. terminating and cleaning up the timer
To do this we synchronize on monitor. The atomic boolean is merely a
convenient container.

Additionally Timeout did not throw any exceptions when the callback
was busy waiting but did set the interrupted flag. To resolve this
we check and throw after the completion of the callback.

This fixes #1241
Copy link
Contributor Author

@mpkorstanje mpkorstanje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brasmusson @aslakhellesoy this code is not pretty. To make it pretty we'd have to effectively make cucumber multithreaded. So I think it'd be best to focus on its validity.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 56.328% when pulling ebe039e on fix-race-condition-in-timeout into db8eeaa on master.

@mpkorstanje mpkorstanje changed the title Fix race condition in Timeout [Core] Fix race condition in Timeout Oct 11, 2017
Copy link
Contributor

@aslakhellesoy aslakhellesoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me @mpkorstanje !

@mpkorstanje mpkorstanje merged commit ca3c2e7 into master Oct 13, 2017
@mpkorstanje mpkorstanje deleted the fix-race-condition-in-timeout branch October 13, 2017 19:40
@lock
Copy link

lock bot commented Oct 24, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 24, 2018
@mpkorstanje mpkorstanje restored the fix-race-condition-in-timeout branch October 4, 2019 18:18
@mpkorstanje mpkorstanje deleted the fix-race-condition-in-timeout branch October 4, 2019 18:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Core] Race condition in Timeout
3 participants