JDK-8319301 : Static analysis warnings after JDK-8318016
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 22
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-11-02
  • Updated: 2023-12-11
  • Resolved: 2023-11-16
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 b25Fixed
Related Reports
Relates :  
Description
(just reporting the sightings, please rename this issue appropriately if this is a real problem).

Sonar reports two new troubles in compileOracle.cpp:

1) "left operand of '-' is a garbage value", when seeing that `line` might not be initialized properly:

  char* end;
  if (!parse_integer<size_t>(line, &end, &s)) {
    jio_snprintf(errorbuf, buf_size, "MemLimit: invalid value");
  }
  bytes_read = (int)(end - line); // <---- here

2) "3rd function call argument is an uninitialized value", because there is an early `return true` from parseMemLimit that does not initialize `value`:

   // Special handling for memlimit
    bool success = (option == CompileCommand::MemLimit) && parseMemLimit(line, value, bytes_read, errorbuf, buf_size);
    if (!success) {
      // Is it a raw number?
      success = sscanf(line, "" INTX_FORMAT "%n", &value, &bytes_read) == 1;
    }
    if (success) {
      total_bytes_read += bytes_read;
      line += bytes_read;
      register_command(matcher, option, value);  // <---- here
Comments
Changeset: eaa4417f Author: Thomas Stuefe <stuefe@openjdk.org> Date: 2023-11-16 07:29:37 +0000 URL: https://git.openjdk.org/jdk/commit/eaa4417f5cdc14cb08c4f694ce9705cb3e0ef167
16-11-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/16631 Date: 2023-11-13 13:34:56 +0000
14-11-2023

[~thartmann] Sorry for the confusion, but I was wrong; this can actually crash if handed a non-number input (-XX:MemLimit,*.*,hallo).
13-11-2023

Okay, thanks. Updated ILW = Crash when parsing command line, -XX:MemLimit with non-number input, no workaround but remove/fix command line = HLM = P3
13-11-2023

Thanks for the details, Thomas. ILW = Benign static analysis warnings, should not be an issue in current code, no workaround = MLH = P4
13-11-2023

Both are valid; both are benign (nothing that could crash).
13-11-2023

3rd function call argument is an uninitialized value https://sonarcloud.io/project/issues?open=AYuOhiE9aUaAJJFME6W_&id=shipilev_jdk
13-11-2023

The left operand of '-' is a garbage value https://sonarcloud.io/project/issues?open=AYuOhiE9aUaAJJFME6W-&id=shipilev_jdk
13-11-2023

I'm waiting with triaging this until it's clear if these are false positives or real issues.
09-11-2023