JDK-8318671 : Potential uninitialized uintx value after JDK-8317683
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 22
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-10-23
  • Updated: 2023-11-21
  • Resolved: 2023-11-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 22
22 b24Fixed
Related Reports
Relates :  
Description
SonarCloud reports a problem in new code added by JDK-8317683.

parseEnumValueAsUintx can return "true" without initializing the "value", at which point we pass uninitialized value to register_command.

Here:

```
  } else if (type == OptionType::Uintx) {
    uintx value;
    // Is it a named enum?
    bool success = parseEnumValueAsUintx(option, line, value, bytes_read, errorbuf, buf_size);
    if (!success) {
      // Is it a raw number?
      success = (sscanf(line, "" UINTX_FORMAT "%n", &value, &bytes_read) == 1);
    }
    if (success) {
      total_bytes_read += bytes_read;
      line += bytes_read;
      register_command(matcher, option, value); <--- value can be not initialized
      return;
    } else {
      jio_snprintf(errorbuf, buf_size, "Value cannot be read for option '%s' of type '%s'", ccname, type_str);
    }
```
Comments
Changeset: 2e34a2eb Author: Thomas Stuefe <stuefe@openjdk.org> Date: 2023-11-15 09:55:51 +0000 URL: https://git.openjdk.org/jdk/commit/2e34a2ebf0f14043b129461b0397495e7e75a38b
15-11-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/16335 Date: 2023-10-24 07:08:07 +0000
24-10-2023

if (strncasecmp(line, "collect", 7) == 0) { value = (uintx)MemStatAction::collect; } else if (strncasecmp(line, "print", 5) == 0) { value = (uintx)MemStatAction::print; print_final_memstat_report = true; } else { jio_snprintf(errorbuf, buf_size, "MemStat: invalid value expected 'collect' or 'print' (omitting value means 'collect')"); } The "error" case is supposed to set the "collect" value but it isn't.
24-10-2023

ILW = Uninitialized value in command line parsing code, no known issues, skip command line argument = MLM = P4
24-10-2023