RFR: 8314743: Use of uninitialized local in SR_initialize after JDK-8314114
Coleen Phillimore
coleenp at openjdk.org
Tue Aug 22 11:50:29 UTC 2023
On Tue, 22 Aug 2023 08:14:12 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> After [JDK-8314114](https://bugs.openjdk.org/browse/JDK-8314114), SonarCloud reports the use on uninitialized `sig` variable in the `warning` line here:
>
>
> int SR_initialize() {
> ...
> int sig;
> bool result = parse_integer(s, &sig);
> if (result && sig > MAX2(SIGSEGV, SIGBUS) && // See 4355769.
> sig < NSIG) { // Must be legal signal and fit into sigflags[].
> PosixSignals::SR_signum = sig;
> } else {
> warning("You set _JAVA_SR_SIGNUM=%d. It must be in range [%d, %d]. Using %d instead.",
> sig, MAX2(SIGSEGV, SIGBUS)+1, NSIG-1, PosixSignals::SR_signum);
> }
>
>
> I think the proper fix is to print out the actual string value.
>
>
> # Before the fix
> % _JAVA_SR_SIGNUM=asdfiasodj1 build/macosx-aarch64-server-fastdebug/images/jdk/bin/java Alloc.java
> OpenJDK 64-Bit Server VM warning: You set _JAVA_SR_SIGNUM=0. It must be in range [12, 31]. Using 31 instead.
>
> # After the fix
> % _JAVA_SR_SIGNUM=asdfiasodj1 build/macosx-aarch64-server-fastdebug/images/jdk/bin/java Alloc.java
> OpenJDK 64-Bit Server VM warning: You set _JAVA_SR_SIGNUM=asdfiasodj1. It must be a number in range [12, 31]. Using 31 instead.
>
>
> Attn @coleenp.
So does SonarCloud know that checking the result of parse_integer, makes 'sig' uninitialized? This is definitely the right fix. Thanks.
-------------
Marked as reviewed by coleenp (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/15381#pullrequestreview-1589245597
More information about the hotspot-runtime-dev
mailing list