RFR: JDK-8319301: Static analysis warnings after JDK-8318016

Tobias Hartmann thartmann at openjdk.org
Tue Nov 14 09:05:32 UTC 2023


On Mon, 13 Nov 2023 13:34:56 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> 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
> 
> 
> Patch fixes both instances and adds new regression test.

Looks good to me otherwise.

test/hotspot/jtreg/compiler/compilercontrol/commands/MemLimitTest.java line 27:

> 25: /*
> 26:  * @test
> 27:  * @bug 8318671

The bug number points to the wrong bug.

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

Marked as reviewed by thartmann (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/16631#pullrequestreview-1729222811
PR Review Comment: https://git.openjdk.org/jdk/pull/16631#discussion_r1392225421


More information about the hotspot-compiler-dev mailing list