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-8299470: sun/jvm/hotspot/SALauncher.java handling of negative rmiport args #11811

Closed
wants to merge 5 commits into from

Conversation

MBaesken
Copy link
Member

@MBaesken MBaesken commented Jan 2, 2023

The test serviceability/sa/sadebugd/SADebugDTest.java can pass under some circumstances a negative rmiport (--rmiport -1) to SALauncher.java.
This leads to a somewhat misleading message
[debugd] Argument is expected for 'rmiport'
(we set an argument [-1] but probably this is not what is really expected) and additionally the real exception is not shown.
Probably also a warning in case of negative rmiport values should be printed because they seem to lead to errors.


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-8299470: sun/jvm/hotspot/SALauncher.java handling of negative rmiport args

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11811

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 2, 2023

👋 Welcome back mbaesken! 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 openjdk bot added the rfr Pull request is ready for review label Jan 2, 2023
@openjdk
Copy link

openjdk bot commented Jan 2, 2023

@MBaesken The following label will be automatically applied to this pull request:

  • serviceability

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

@openjdk openjdk bot added the serviceability serviceability-dev@openjdk.org label Jan 2, 2023
@mlbridge
Copy link

mlbridge bot commented Jan 2, 2023

Webrevs

@MBaesken
Copy link
Member Author

MBaesken commented Jan 4, 2023

I adjusted the exception message a bit to show what is wrong (-1 as an argument is not expected/supported).
Removed one warning output because it seems we do not get there.

Any reviews ?

Copy link
Contributor

@RealCLanger RealCLanger left a comment

Choose a reason for hiding this comment

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

I've got one suggestion, plus, the copyright year now is 2023 😉

@@ -500,6 +500,8 @@ public static void main(String[] args) {
func.accept(oldArgs);
}
} catch (SAGetoptException e) {
System.err.println("SA agent option related exception occured");
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you could do here:
System.err.println("SA agent option exception occured: " + e.getMessage);
and remove the System.err.println(e.getMessage()); in line 505.

@openjdk
Copy link

openjdk bot commented Jan 4, 2023

@MBaesken 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:

8299470: sun/jvm/hotspot/SALauncher.java handling of negative rmiport args

Reviewed-by: clanger, sspitsyn, kevinw

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 39 new commits pushed to the master branch:

  • 578c287: 8081507: Open or Save button in JFileChooser has OK title in GTK LaF
  • 5ae6de8: 8299296: Write a test to verify the components selection sends ItemEvent
  • 3b374c0: 8299439: java/text/Format/NumberFormat/CurrencyFormat.java fails for hr_HR
  • 7dcc689: 8299563: Fix typos
  • 44be5ed: 8219810: javac throws NullPointerException
  • b9758d2: 8200610: Compiling fails with java.nio.file.ReadOnlyFileSystemException
  • df1caf9: Merge
  • a17f505: 8299476: PPC64 Zero build fails after JDK-8286302
  • b743519: 8293824: gc/whitebox/TestConcMarkCycleWB.java failed "RuntimeException: assertTrue: expected true, was false"
  • 8254cbb: 8299483: ProblemList java/text/Format/NumberFormat/CurrencyFormat.java
  • ... and 29 more: https://git.openjdk.org/jdk/compare/8a10eef408f10d1a6d698a6f74942111b72d0765...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 Jan 4, 2023
@kevinjwalls
Copy link
Contributor

kevinjwalls commented Jan 4, 2023

The changes here to log a better error are I think good (maybe adding the stacktrace printing is not needed now the error is more understandable!), but aborting the launch attempt in the caller, if it gets -1 when trying to find a free port, should be even clearer?

In
test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java

the method testWithPid() finds an rmiPort:

final int rmiPort = useRmiPort ? Utils.findUnreservedFreePort(REGISTRY_DEFAULT_PORT, registryPort) : -1;

...but can proceed to launch even if it gets the -1 value which findUnreservedFreePort could return? That looks like a mistake.

In the "if (useRmiPort) {" block, we should be failing the test if rmiPort is -1, saying something like
"cannot find an rmiPort, findUnreservedFreePort returns -1"

A similar abort if setting registryPort gets -1 might also be good?

@MBaesken
Copy link
Member Author

MBaesken commented Jan 4, 2023

In the "if (useRmiPort) {" block, we should be failing the test if rmiPort is -1, saying something like "cannot find an rmiPort, findUnreservedFreePort returns -1"

A similar abort if setting registryPort gets -1 might also be good?

Hi Kevin, I think you are correct, adjusting the test test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java in those two cases (rmiPort / registryPort -1) probably makes sense. Should we do it in another JBS issue or here ?
Additionally , should we fail the test in these cases , or pass with some warning - message ?

@kevinjwalls
Copy link
Contributor

SADebugDTest is only one test, so seems OK to have it fail as soon as we realise we need a port, and it has a value of -1.

I would do it in this change as they are so connected, but really whichever works best for you. (I don't see other uses of findUnreservedFreePort() in the same test hierarchy, so this task should not keep on growing... 8-) )

@MBaesken
Copy link
Member Author

MBaesken commented Jan 4, 2023

SADebugDTest is only one test, so seems OK to have it fail as soon as we realise we need a port, and it has a value of -1.

I would do it in this change as they are so connected, but really whichever works best for you. (I don't see other uses of findUnreservedFreePort() in the same test hierarchy, so this task should not keep on growing... 8-) )

Hi Kevin, I adjusted the mentioned test, please have a look !

@kevinjwalls
Copy link
Contributor

Looks good!

Rereading the change, occured should be "occurred" (we do have a lot of "occured" in the JDK, but many more "occurred")
On the line after that, I don't think we should introduce the stacktrace. The user is getting a more readable error message already...
In SAGetopt.java you single-quote the 'opt' value, but could we do the same to the _argv[_optind] value.

Then can you could make it "a registryPort" rather than "an", and I think I'm done with comments.

Thanks!

Copy link
Contributor

@sspitsyn sspitsyn left a comment

Choose a reason for hiding this comment

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

Looks good.
Thanks,
Serguei

@kevinjwalls
Copy link
Contributor

kevinjwalls commented Jan 5, 2023

Thanks for updating.
I do think we should remove the e.printStackTrace() that was added in src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java
as this is a message for the user.
In the test, those new RuntimeExceptions will produce a stacktrace for when we look at the failing test.

@MBaesken
Copy link
Member Author

MBaesken commented Jan 5, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Jan 5, 2023

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

  • 578c287: 8081507: Open or Save button in JFileChooser has OK title in GTK LaF
  • 5ae6de8: 8299296: Write a test to verify the components selection sends ItemEvent
  • 3b374c0: 8299439: java/text/Format/NumberFormat/CurrencyFormat.java fails for hr_HR
  • 7dcc689: 8299563: Fix typos
  • 44be5ed: 8219810: javac throws NullPointerException
  • b9758d2: 8200610: Compiling fails with java.nio.file.ReadOnlyFileSystemException
  • df1caf9: Merge
  • a17f505: 8299476: PPC64 Zero build fails after JDK-8286302
  • b743519: 8293824: gc/whitebox/TestConcMarkCycleWB.java failed "RuntimeException: assertTrue: expected true, was false"
  • 8254cbb: 8299483: ProblemList java/text/Format/NumberFormat/CurrencyFormat.java
  • ... and 29 more: https://git.openjdk.org/jdk/compare/8a10eef408f10d1a6d698a6f74942111b72d0765...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jan 5, 2023

@MBaesken Pushed as commit 2ccdefc.

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

@dholmes-ora
Copy link
Member

This change has introduced a test failure in our tier 5 CI testing:

https://bugs.openjdk.org/browse/JDK-8299700

@dholmes-ora
Copy link
Member

I missed an issue had already been filed for the failure.

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

Successfully merging this pull request may close these issues.

5 participants