RFR: 8325542: CTW: Runner can produce negative StressSeed
Joshua Cao
duke at openjdk.org
Fri Feb 16 22:00:35 UTC 2024
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 `./ctw.sh modules:java.base`
-------------
Commit messages:
- 8325542: CTW: Runner can produce negative StressSeed
Changes: https://git.openjdk.org/jdk/pull/17896/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=17896&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8325542
Stats: 3 lines in 1 file changed: 1 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/17896.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/17896/head:pull/17896
PR: https://git.openjdk.org/jdk/pull/17896
More information about the hotspot-compiler-dev
mailing list