RFR: 8248862: Implement Enhanced Pseudo-Random Number Generators [v3]
Brett Okken
github.com+2996845+bokken at openjdk.java.net
Wed Jan 6 15:40:02 UTC 2021
On Wed, 25 Nov 2020 14:07:04 GMT, Rémi Forax <github.com+828220+forax at openjdk.org> wrote:
>> Jim Laskey has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8248862: Implement Enhanced Pseudo-Random Number Generators
>>
>> Changes to RandomGeneratorFactory requested by @PaulSandoz
>
> src/java.base/share/classes/java/util/random/RandomGeneratorFactory.java line 335:
>
>> 333: ctorBytes = tmpCtorBytes;
>> 334: ctorLong = tmpCtorLong;
>> 335: ctor = tmpCtor;
>
> This one is a volatile write, so the idea is that ctorBytes and ctorLong does not need to be volatile too, which i think is not true if there is a code somewhere that uses ctorBytes or ctorLong without reading ctor.
> This code is too smart for me, i'm pretty sure it is wrong too on non TSO cpu.
The 2 uses call ensureConstructors, which calls this method, which reads ctor.
The memory model guarantees this to be safe, even on non tso hardware.
https://shipilev.net/blog/2016/close-encounters-of-jmm-kind/#pitfall-avoiding
-------------
PR: https://git.openjdk.java.net/jdk/pull/1292
More information about the security-dev
mailing list