RFR: 8281472: JVM options processing silently truncates large illegal options values

Harold Seigel hseigel at openjdk.java.net
Fri Feb 18 13:30:52 UTC 2022


On Thu, 17 Feb 2022 22:28:56 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Please review this change to fix JDK-8281472.  The fix prevents truncation of large illegal option values by rejecting those values if they exceed the range of their type.  For example, it rejects values of int options that are not between max_int and min_int.
>> 
>> The fix was tested by running Mach5 tiers 1-2 on Linux, Mac OS, and Windows, and Mach5 tiers 3-5 on Linux-x64 and Windows-x64.
>> 
>> Thanks, Harold
>
> src/hotspot/share/runtime/arguments.cpp line 874:
> 
>> 872:     if (v > (julong)max_juint + 1) {
>> 873:       return false;
>> 874:     }
> 
> This seems very suspicious. Where is the code that depends on this?

Test test/hotspot/jtreg/gc/arguments/TestParallelGCThreads.java has the following code:


    // 4294967295 == (unsigned int) -1
    // So setting ParallelGCThreads=4294967295 should give back 4294967295
    // and setting ParallelGCThreads=4294967296 should give back 0. (SerialGC is ok with ParallelGCThreads=0)
    for (long i = 4294967295L; i <= 4294967296L; i++) {
      long count = getParallelGCThreadCount(
          "-XX:+UseSerialGC",
          "-XX:ParallelGCThreads=" + i,
          "-XX:+PrintFlagsFinal",
          "-version");
      Asserts.assertEQ(count, i % 4294967296L, "Specifying ParallelGCThreads=" + i + " does not set the thread count properly!");
    }
  }

-------------

PR: https://git.openjdk.java.net/jdk/pull/7522


More information about the hotspot-dev mailing list