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

Harold Seigel hseigel at openjdk.java.net
Fri Feb 18 19:29:53 UTC 2022


On Fri, 18 Feb 2022 18:47:30 GMT, Ioi Lam <iklam 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 889:
> 
>> 887:     // -9223372036854775808.  Negating intx_v for such values will erroneously
>> 888:     // make them positive.
>> 889:     if (is_neg && intx_v > 0) {
> 
> I found it hard to reason with the casts such as `(uintx)(min_intx)`, even though they appear to be correct. I think this will be simpler and more readable:
> 
> 
> intx_v = (intx) v;
> if (is_neg) {
>   intx_v = - intx_v;
>   if (intx_v > 0) {
>     return false; // underflow
>   }
> } else {
>   if (intx_v < 0) {
>     return false; // overflow
>   }
> }

That doesn't work for intx options set to min_intx, such as MaxJNILocalCapacity=-9223372036854775808.  Perhaps min_intx should be special cased?

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

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


More information about the hotspot-dev mailing list