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

8274982: Add a test for 8269574. #5889

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

@lepestock
Copy link
Contributor

@lepestock lepestock commented Oct 11, 2021

This PR contains a relatively simple test which verifies that JVMTI-agents are correctly informed about exceptions caught in C2-compiled code. The 8269574 introduces pre-allocated exceptions in some paths, so the test tries to produce a number of various exceptions and check that provided small JVMTI agent got notified about all of them.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5889/head:pull/5889
$ git checkout pull/5889

Update a local copy of the PR:
$ git checkout pull/5889
$ git pull https://git.openjdk.java.net/jdk pull/5889/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5889

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5889.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Oct 11, 2021

👋 Welcome back enikitin! 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 label Oct 11, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Oct 11, 2021

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

  • hotspot-compiler

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.

@mlbridge
Copy link

@mlbridge mlbridge bot commented Oct 11, 2021

Webrevs

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Nov 8, 2021

@lepestock This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@vnkozlov
Copy link
Contributor

@vnkozlov vnkozlov commented Nov 10, 2021

/labels add serviceability

@vnkozlov
Copy link
Contributor

@vnkozlov vnkozlov commented Nov 10, 2021

Someone from serviceability group have to look on this test too.

@openjdk
Copy link

@openjdk openjdk bot commented Nov 10, 2021

@vnkozlov Unknown command labels - for a list of valid commands use /help.

@vnkozlov
Copy link
Contributor

@vnkozlov vnkozlov commented Nov 10, 2021

/label add serviceability

@openjdk
Copy link

@openjdk openjdk bot commented Nov 10, 2021

@vnkozlov
The serviceability label was successfully added.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

I am fine with changes.
What testing was done? What testing tiers were run?

}

Asserts.assertEQ(
TriggerBuiltinExceptionsTest.caughtByJVMTIAgent(), caughtByJavaTest,
Copy link
Contributor

@sspitsyn sspitsyn Nov 10, 2021

Choose a reason for hiding this comment

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

What is the reason to use the class name prefix for methods? :
TriggerBuiltinExceptionsTest.compileMethodOrThrow
TriggerBuiltinExceptionsTest.methodToCompile
TriggerBuiltinExceptionsTest.caughtByJVMTIAgent
It is not really needed, tight?

Copy link
Contributor Author

@lepestock lepestock Dec 16, 2021

Choose a reason for hiding this comment

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

Style habits, acquired in previons job... fixed.

Copy link
Contributor

@sspitsyn sspitsyn left a comment

Hi Evgeny,
New test looks good to me.
I've inlined a couple of minor comments/suggestions.
Thanks,
Serguei

break;
}

} while (false);
Copy link
Contributor

@sspitsyn sspitsyn Nov 10, 2021

Choose a reason for hiding this comment

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

I'm not sure why the while (false) loop is needed.
You can always return JNI_ERR instead of break in all places where the
result != JVMTI_ERROR_NONE is detected and return JNI_OK at the end.
Is it to for one-return style?

Copy link
Contributor Author

@lepestock lepestock Dec 16, 2021

Choose a reason for hiding this comment

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

Remnants from a previous, draft version. Fixed (along with unnecessary 'successfull' variable removal).

@openjdk
Copy link

@openjdk openjdk bot commented Nov 10, 2021

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

8274982: Add a test for 8269574.

Reviewed-by: sspitsyn, lmesnik

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

  • 634afe8: Merge
  • be6b90d: 8278574: update --help-extra message to include default value of --finalization option
  • aec1b03: 8278389: SuspendibleThreadSet::_suspend_all should be volatile/atomic
  • e82310f: 8278575: update jcmd GC.finalizer_info to list finalization status
  • 7ce4aa8: 8276982: VM.class_hierarchy jcmd help output and man page text needs clarifications/improvements
  • 197c9f5: 8268573: Remove expired flags in JDK 19
  • 8f5fdd8: 8278587: StringTokenizer(String, String, boolean) documentation bug
  • 20db780: 8277868: Use Comparable.compare() instead of surrogate code
  • 937126b: 8278551: Shenandoah: Adopt WorkerThread::worker_id() to replace Shenandoah specific implementation
  • f15a59c: 8278756: Parallel: Drop PSOldGen::_reserved
  • ... and 48 more: https://git.openjdk.java.net/jdk/compare/15996e407563eda844266f1cbcdc20be74b4b4e4...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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@vnkozlov, @sspitsyn, @dholmes-ora, @lmesnik) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready label Nov 10, 2021
* @library /test/lib /
*
* @build sun.hotspot.WhiteBox
* @build compiler.jvmti.TriggerBuiltinExceptionsTest
Copy link
Member

@dholmes-ora dholmes-ora Nov 11, 2021

Choose a reason for hiding this comment

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

Explicit build directive should not be needed.

Copy link
Contributor Author

@lepestock lepestock Dec 16, 2021

Choose a reason for hiding this comment

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

Fixed, thanks

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Just a couple of minor issues, not a review of functionality.


public class TriggerBuiltinExceptionsTest {
private static final WhiteBox WB = WhiteBox.getWhiteBox();
private static final int ITERATIONS = 30; //Arbitrary value, feel free to change
Copy link
Member

@dholmes-ora dholmes-ora Nov 11, 2021

Choose a reason for hiding this comment

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

Style nit: space after //

Copy link
Contributor Author

@lepestock lepestock Dec 16, 2021

Choose a reason for hiding this comment

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

Fixed.

* @test
* @bug 8269574
* @summary Verifies that exceptions are reported correctly to JVMTI in the compiled code
* @requires vm.jvmti
Copy link
Member

@dholmes-ora dholmes-ora Nov 11, 2021

Choose a reason for hiding this comment

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

You also require the JIT

Copy link
Contributor Author

@lepestock lepestock Dec 16, 2021

Choose a reason for hiding this comment

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

Added a requirement for the c1 or c2.

Copy link
Member

@lmesnik lmesnik Dec 16, 2021

Choose a reason for hiding this comment

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

Really, we don't add @requires for jit compiler. There are a lot of tests that fail with Xnt.

Copy link
Member

@dholmes-ora dholmes-ora Dec 16, 2021

Choose a reason for hiding this comment

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

Tests outside of the compiler area which explicitly use features like WB.enqueueMethodForCompilation which explicitly will fail if there is no JIT either require the JIT or exclude running with Zero. See for example:

./runtime/Nestmates/protectionDomain/TestDifferentProtectionDomains.java
./runtime/Unsafe/InternalErrorTest.java
./runtime/exceptionMsgs/AbstractMethodError/AbstractMethodErrorTest.java

EDIT: except of course this test is in the compiler area . Okay perhaps overkill - sorry for the noise.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

I will leave approval to @sspitsyn and @dholmes-ora

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Dec 10, 2021

@lepestock This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!


} while (false);

return (result == JNI_OK) || (result == JVMTI_ERROR_NONE) ? JNI_OK : JNI_ERR;
Copy link
Member

@lmesnik lmesnik Dec 16, 2021

Choose a reason for hiding this comment

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

Seems (result == JNI_OK) || (result == JVMTI_ERROR_NONE) should be (result == JNI_OK) && (result == JVMTI_ERROR_NONE).

Really, I think it would be better to replace
do {
...
break;
..
} while (false)
with multiply return.

It makes logic simpler and style compliant to all jvmti tests.

* @test
* @bug 8269574
* @summary Verifies that exceptions are reported correctly to JVMTI in the compiled code
* @requires vm.jvmti
Copy link
Member

@lmesnik lmesnik Dec 16, 2021

Choose a reason for hiding this comment

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

Really, we don't add @requires for jit compiler. There are a lot of tests that fail with Xnt.

Copy link
Member

@dholmes-ora dholmes-ora left a comment

A few more comments below.

Thanks,
David

* @test
* @bug 8269574
* @summary Verifies that exceptions are reported correctly to JVMTI in the compiled code
* @requires vm.jvmti
Copy link
Member

@dholmes-ora dholmes-ora Dec 16, 2021

Choose a reason for hiding this comment

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

Tests outside of the compiler area which explicitly use features like WB.enqueueMethodForCompilation which explicitly will fail if there is no JIT either require the JIT or exclude running with Zero. See for example:

./runtime/Nestmates/protectionDomain/TestDifferentProtectionDomains.java
./runtime/Unsafe/InternalErrorTest.java
./runtime/exceptionMsgs/AbstractMethodError/AbstractMethodErrorTest.java

EDIT: except of course this test is in the compiler area . Okay perhaps overkill - sorry for the noise.

callbackException(jvmtiEnv *jvmti_env, JNIEnv* jni_env,
jthread thread, jmethodID method,
jlocation location, jobject exception,
jmethodID catch_method, jlocation catch_location) {
exceptions_caught += 1;
}
Copy link
Member

@dholmes-ora dholmes-ora Dec 16, 2021

Choose a reason for hiding this comment

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

IIUC this will count all exceptions occurring in any thread and in relation to any method. There are behind-the-scenes exceptions that can occur which may cause this to count exceptions not related to the test. I think you need to only count those thrown in the method of interest, for reliability.

@lepestock
Copy link
Contributor Author

@lepestock lepestock commented Dec 17, 2021

What testing was done? What testing tiers were run?

I've run with intentionally broken prod. code (the 8269574 unfixed) - the test catches the problem. Additionally, I've run the test and tiers 1-2-3.

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Jan 14, 2022

@lepestock This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment