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

Make {Synchronous,General}NonBlockingStepExecution.stopCause volatile #46

Merged
merged 1 commit into from
Nov 12, 2019

Conversation

slonopotamus
Copy link
Contributor

Reasoning: stopCause is used from multiple threads. In order to guarantee that task thread sees updated value, JMM requires field to be volatile.

Copy link
Member

@dwnusbaum dwnusbaum left a comment

Choose a reason for hiding this comment

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

@slonopotamus Thanks for the PR! Did you run into a bug in relation to this, or is it just something you noticed while reading the code? I think GeneralNonBlockingStepExecution would also need to be updated, right?

I have no idea how likely this is to be a problem in practice, but it seems fine so that start doesn't see an outdated value if an exception is thrown.

@slonopotamus
Copy link
Contributor Author

I was just reading through the code, no real-life bug. Yes, GeneralNonBlockingStepExecution has the same issue (if my understanding of Java memory model is correct).

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

And yes it should probably be extended to GeneralNonBlockingStepExecution too.

Reasoning: stopCause is used from multiple threads. In order to guarantee that task thread sees updated value, JMM requires field to be volatile.
@slonopotamus slonopotamus changed the title Make SynchronousNonBlockingStepExecution.stopCause volatile Make {Synchronous,General}NonBlockingStepExecution.stopCause volatile Nov 10, 2019
@dwnusbaum dwnusbaum merged commit 0514ef6 into jenkinsci:master Nov 12, 2019
@slonopotamus slonopotamus deleted the stopCause-volatile branch November 19, 2019 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants