Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK-8318671: Potential uninitialized uintx value after JDK-8317683 #16335

Conversation

tstuefe
Copy link
Member

@tstuefe tstuefe commented Oct 24, 2023

When using 'MemStat' CompileCommand, we accidentally register the command if an invalid suboption had been specified. Fixed, added regression test (verified).


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8318671: Potential uninitialized uintx value after JDK-8317683 (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16335/head:pull/16335
$ git checkout pull/16335

Update a local copy of the PR:
$ git checkout pull/16335
$ git pull https://git.openjdk.org/jdk.git pull/16335/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 16335

View PR using the GUI difftool:
$ git pr show -t 16335

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16335.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 24, 2023

👋 Welcome back stuefe! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 24, 2023

@tstuefe The following labels will be automatically applied to this pull request:

  • hotspot-compiler
  • serviceability

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org hotspot-compiler hotspot-compiler-dev@openjdk.org labels Oct 24, 2023
@tstuefe tstuefe marked this pull request as ready for review October 24, 2023 08:56
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 24, 2023
@mlbridge
Copy link

mlbridge bot commented Oct 24, 2023

Webrevs

Comment on lines 649 to 650
jio_snprintf(errorbuf, buf_size, "MemStat: invalid value expected 'collect' or 'print' (omitting value means 'collect')");
return handled_err;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If "omitting value means 'collect'" then why do we not simply set value = (uintx)MemStatAction::collect ? Otherwise what is that message supposed to mean?

Ternary return values are unpleasant.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If "omitting value means 'collect'" then why do we not simply set value = (uintx)MemStatAction::collect ? Otherwise what is that message supposed to mean?

We only enter this function if a value for this command had been given (-XX:CompileCommand=<command>,<method>[,<value>]). The default case is handled somewhere else (CompilerOracle::parse_from_line).

Ternary return values are unpleasant.

As, on a general base? You don't like the number three :-) ?

Here, we have to distinguish between:

  • not handled, its not a command option that accepts enum strings
  • handled, with two variants: handled, had an error, and handled, had no error. Only in the latter case we want to register the command.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I'll butt out. The comment doesn't make sense to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dholmes-ora Sorry if I came across as flippant; that was not my intention. If you can stomach it, I rewrote the patch to be hopefully easier to read. Thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I didn't take it that way at all. The new patch does seem easier to read, but I will still defer to compiler folk to review this.

@openjdk openjdk bot removed the rfr Pull request is ready for review label Oct 26, 2023
* java.management
* @run main/othervm -XX:CompileCommand=memstat,*.*,collect CompilerMemoryStatisticTest
*/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer hint: Removed because its redundant with the syntax check introduced in MemStatTest.java

@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 26, 2023
Copy link
Contributor

@jdksjolen jdksjolen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

This looks good to me, I've got a couple of comments (one is just a nit). I'll leave it to the compiler folks for approval.

Copy link
Member

@TobiHartmann TobiHartmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me.

@openjdk
Copy link

openjdk bot commented Oct 31, 2023

@tstuefe This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8318671: Potential uninitialized uintx value after JDK-8317683

Reviewed-by: thartmann, shade

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 37 new commits pushed to the master branch:

  • bad6999: 8313672: C2: PhaseCCP does not correctly track analysis dependencies involving shift, convert, and mask
  • fbe1937: 8319955: Improve dependencies removal during class unloading
  • 4c1540b: 8287284: C2: loop optimization performs split_thru_phi infinitely many times
  • 70f0c01: 8320054: Remove unused _count from NMT walker classes
  • e7486e8: 8315986: [macos14] javax/swing/JMenuItem/4654927/bug4654927.java: component must be showing on the screen to determine its location
  • a6343c0: 8319999: Refactor MetaspaceShared::use_full_module_graph()
  • d9a89c5: 8319572: Test jdk/incubator/vector/LoadJsvmlTest.java ignores VM flags
  • 1e76ba0: 8319439: Move BufferNode from PtrQueue files to new files
  • d5abe49: 8319628: DateFormat does not mention IllegalArgumentException for invalid style args
  • d725b73: 8301310: The SendRawSysexMessage test may cause a JVM crash
  • ... and 27 more: https://git.openjdk.org/jdk/compare/03db82818b905f21cb5ad1d56a687e238b4a6e33...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 31, 2023
@TobiHartmann
Copy link
Member

I think this is ready for integration given that both @dholmes-ora and @jdksjolen are okay with it.

@tstuefe
Copy link
Member Author

tstuefe commented Nov 13, 2023

I think this is ready for integration given that both @dholmes-ora and @jdksjolen are okay with it.

Well, they did not approve yet; @jdksjolen or @dholmes-ora, if you are happy with this, could you hit the big green button please?

@dholmes-ora
Copy link
Member

@TobiHartmann both @jdksjolen and myself indicated we would defer to the compiler team to review/approve this. I only had some drive-by comments.

@tstuefe
Copy link
Member Author

tstuefe commented Nov 14, 2023

@shipilev maybe, as bug owner?

total_bytes_read += bytes_read;
line += bytes_read;
register_command(matcher, option, value);
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this return removed? All other cases in this file have the return after register_command, which I assume the style here: once any command is properly matched, return.

static bool parseEnumValueAsUintx(enum CompileCommand option, const char* line, uintx& value, int& bytes_read, char* errorbuf, const int buf_size) {
// Parse an uintx-based option value. Also takes care of parsing enum values for options that are enums.
// Returns true if ok, false if the value could not be parsed.
static bool parseUintxValue(enum CompileCommand option, const char* line, uintx& value, int& bytes_read) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is honestly weird to see parse***Uintx***Value dealing with enums, and be specialized for MemStat. Can you reflow this to match how MemLimit does it?

bool success = (option == CompileCommand::MemLimit) && parseMemLimit(line, value, bytes_read, errorbuf, buf_size);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, rewritten in the style of #16631. Retested too. Let's get this out of the door, please.

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right, new version looks significantly better, thanks!

@tstuefe
Copy link
Member Author

tstuefe commented Nov 15, 2023

MacOS error unrelated.

/integrate

@openjdk
Copy link

openjdk bot commented Nov 15, 2023

Going to push as commit 2e34a2e.
Since your change was applied there have been 38 commits pushed to the master branch:

  • fac6b51: 8319781: RISC-V: Refactor UseRVV related checks
  • bad6999: 8313672: C2: PhaseCCP does not correctly track analysis dependencies involving shift, convert, and mask
  • fbe1937: 8319955: Improve dependencies removal during class unloading
  • 4c1540b: 8287284: C2: loop optimization performs split_thru_phi infinitely many times
  • 70f0c01: 8320054: Remove unused _count from NMT walker classes
  • e7486e8: 8315986: [macos14] javax/swing/JMenuItem/4654927/bug4654927.java: component must be showing on the screen to determine its location
  • a6343c0: 8319999: Refactor MetaspaceShared::use_full_module_graph()
  • d9a89c5: 8319572: Test jdk/incubator/vector/LoadJsvmlTest.java ignores VM flags
  • 1e76ba0: 8319439: Move BufferNode from PtrQueue files to new files
  • d5abe49: 8319628: DateFormat does not mention IllegalArgumentException for invalid style args
  • ... and 28 more: https://git.openjdk.org/jdk/compare/03db82818b905f21cb5ad1d56a687e238b4a6e33...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 15, 2023
@openjdk openjdk bot closed this Nov 15, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 15, 2023
@openjdk
Copy link

openjdk bot commented Nov 15, 2023

@tstuefe Pushed as commit 2e34a2e.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org
5 participants