RFR: 8325542: CTW: Runner can produce negative StressSeed
Aleksey Shipilev
shade at openjdk.org
Mon Feb 19 20:01:57 UTC 2024
On Fri, 16 Feb 2024 21:55:03 GMT, Joshua Cao <duke at openjdk.org> wrote:
> CtwRunner does `abs(random.nextInt())`, which would break when random returns Integer.MIN_VALUE. Its abs() would be negative, which would be caught by JVM argument parsing code as incorrectly specified option. This would yield a very rare CTW failure.
>
> We fix this by using `nextInt(Integer.MAX_VALUE)`, which always returns a non-negative number in [0, MAX_VALUE). This is what [jcstress does](https://github.com/openjdk/jcstress/blob/84bd76e115604e81e721674eff0ff39c5a3bf3b8/jcstress-core/src/main/java/org/openjdk/jcstress/vm/VMSupport.java#L565).
>
> I also make a change so that `rng` has explicit type. I think we prefer explicit types for most cases.
>
> Tested with `./ctwrunner.sh modules:java.base`
I'll wait for another reviewer before sponsoring.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/17896#issuecomment-1953089486
More information about the hotspot-compiler-dev
mailing list