Skip to content

properly synchronize globalInlineCount#5943

Merged
kares merged 1 commit intojruby:masterfrom
ahorek:icount
Oct 26, 2019
Merged

properly synchronize globalInlineCount#5943
kares merged 1 commit intojruby:masterfrom
ahorek:icount

Conversation

@ahorek
Copy link
Contributor

@ahorek ahorek commented Oct 23, 2019

synchronization using a boxed primitive isn't reliable, because the field's value could be changed while a thread is in a synchronized block.

@kares
Copy link
Member

kares commented Oct 24, 2019

nice find, this piece is just quite weird (there's still globalInlineCount++ against the boxed int).
@ahorek how do you feel about refactoring to simply use an AtomicInt (without synchronize) ?

@enebo
Copy link
Member

enebo commented Oct 24, 2019

with PR as it is globalInlineCount should be made an int. The usage of this synchronize was so narrow I don't think in practice we would ever see the field change while it is synched. That said, either suggested fix is better (I would prefer AtomicInt myself).

@kares kares merged commit 1908176 into jruby:master Oct 26, 2019
@kares kares added this to the JRuby 9.2.9.0 milestone Oct 26, 2019
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