Skip to content

8299329: Assertion failure with fastdebug build when trying to use CDS without classpath #11781

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

Closed
wants to merge 6 commits into from

Conversation

ashu-mehra
Copy link
Contributor

@ashu-mehra ashu-mehra commented Dec 23, 2022

It appears longest_common_app_classpath_prefix_len() is not returning correct value when there is no file separator in the path being searched backwards. Instead of returning 0 it return 1.

In case of empty classpath, it can result in assertion failure in check_paths():

assert(strlen(rp_array->at(i)) > (size_t)runtime_prefix_len, "sanity");

It can also result in incorrectly validating the app classpaths if they only differ by first character. Eg:

Dump time:
-cp hello.jar
Run time:
-cp mello.jar

This would not result in classpath mismatch!

This fix updates longest_common_app_classpath_prefix_len() to return 0 if no file separator character is found.

Signed-off-by: Ashutosh Mehra asmehra@redhat.com


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-8299329: Assertion failure with fastdebug build when trying to use CDS without classpath

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11781

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

Using diff file

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

…S without classpath

Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
@bridgekeeper
Copy link

bridgekeeper bot commented Dec 23, 2022

👋 Welcome back ashu-mehra! 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 Dec 23, 2022
@openjdk
Copy link

openjdk bot commented Dec 23, 2022

@ashu-mehra The following label will be automatically applied to this pull request:

  • hotspot-runtime

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 hotspot-runtime hotspot-runtime-dev@openjdk.org label Dec 23, 2022
@mlbridge
Copy link

mlbridge bot commented Dec 23, 2022

Webrevs

@jerboaa
Copy link
Contributor

jerboaa commented Dec 23, 2022

Could we add a test for this a la test/hotspot/jtreg/runtime/cds/appcds/WrongClasspath.java?

@ashu-mehra
Copy link
Contributor Author

@jerboaa I see WrongClasspath.java already has a test for "no classpath" condition, but it is not failing with debug build.
The command line used for running "no classpaht" test reveals it is actually running with a classpath:

/work/jdk/build/base-fd/images/jdk/bin/java -cp /work/jdk/JTwork/classes/runtime/cds/appcds/WrongClasspath.d:/work/jdk/test/hotspot/jtreg/runtime/cds/appcds:/work/jdk/JTwork/classes/test/lib:/work/jdk/test/lib:/work/jtreg/build/images/jtreg/lib/javatest.jar:/work/jtreg/build/images/jtreg/lib/jtreg.jar -Xshare:on -showversion -XX:SharedArchiveFile=/work/jdk/JTwork/scratch/appcds-15h18m10s791.jsa -Dtest.timeout.factor=1.0 -XX:+UnlockDiagnosticVMOptions -XX:VerifyArchivedFields=1 -Xlog:cds Hello

The classpath is appended by jdk.test.lib.process.ProcessTools#createJavaProcessBuilder():

        args.add("-cp");
        args.add(System.getProperty("java.class.path"));

That means the "no classpath" test is not really testing what it is expected to.

@iklam
Copy link
Member

iklam commented Dec 24, 2022

@jerboaa I see WrongClasspath.java already has a test for "no classpath" condition, but it is not failing with debug build. The command line used for running "no classpaht" test reveals it is actually running with a classpath:

/work/jdk/build/base-fd/images/jdk/bin/java -cp /work/jdk/JTwork/classes/runtime/cds/appcds/WrongClasspath.d:/work/jdk/test/hotspot/jtreg/runtime/cds/appcds:/work/jdk/JTwork/classes/test/lib:/work/jdk/test/lib:/work/jtreg/build/images/jtreg/lib/javatest.jar:/work/jtreg/build/images/jtreg/lib/jtreg.jar -Xshare:on -showversion -XX:SharedArchiveFile=/work/jdk/JTwork/scratch/appcds-15h18m10s791.jsa -Dtest.timeout.factor=1.0 -XX:+UnlockDiagnosticVMOptions -XX:VerifyArchivedFields=1 -Xlog:cds Hello

The classpath is appended by jdk.test.lib.process.ProcessTools#createJavaProcessBuilder():

        args.add("-cp");
        args.add(System.getProperty("java.class.path"));

That means the "no classpath" test is not really testing what it is expected to.

Maybe we can do this?

    // Then try to execute the archive without -classpath -- it should fail
    TestCommon.run(
-       /* "-cp", appJar, */ // <- uncomment this and the execution should succeed
+       // Force classpath to be the empty string. Note: -cp "" doesn't work on Windows.
+       "-Djava.class.path=",
        "-Xlog:cds",
        "Hello")
        .assertAbnormalExit(unableToUseMsg, mismatchMsg, hintMsg);

That should override the -cp parameter given by createJavaProcessBuilder, which appears earlier in the command-line.

Also, I think you should add the -cp hello.jar vs -cp mello.jar test case into WrongClasspath.java.

Thanks!

Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
@openjdk openjdk bot removed the rfr Pull request is ready for review label Jan 4, 2023
Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 4, 2023
@ashu-mehra
Copy link
Contributor Author

Adding -Djava.class.path= wouldn't work as it is different than the case when no classpath is specified. When there is no classpath specified, launcher adds "." as the classpath.
To fix the "no-classpath" test I added another system property test.noclasspath to avoid setting 'cp' in ProcessTools#createJavaProcessBuilder. I realized the CLASSPATH env variable is also set when the test Java process is created, so that needs to be removed as well.

Also, I think you should add the -cp hello.jar vs -cp mello.jar test case into WrongClasspath.java.

I have added this test as well.

Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
Copy link
Member

@iklam iklam left a comment

Choose a reason for hiding this comment

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

LGTM

@openjdk
Copy link

openjdk bot commented Jan 5, 2023

@ashu-mehra 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:

8299329: Assertion failure with fastdebug build when trying to use CDS without classpath

Reviewed-by: iklam, ccheung

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

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 (@iklam, @calvinccheung) 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 Pull request is ready to be integrated label Jan 5, 2023
Copy link
Member

@calvinccheung calvinccheung left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this. Just one nit below.

Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
@ashu-mehra
Copy link
Contributor Author

There is a test failure on macos-x64 not related to the changes in this PR.
The test test/hotspot/jtreg/gc/g1/TestVerifyGCType.java fails at:

java.lang.RuntimeException: Missing expected verification pattern Verifying After GC for: Pause Young (Prepare Mixed): expected true, was false
	at jdk.test.lib.Asserts.fail(Asserts.java:594)
	at jdk.test.lib.Asserts.assertTrue(Asserts.java:486)
	at gc.g1.TestVerifyGCType.verifyType(TestVerifyGCType.java:201)
	at gc.g1.TestVerifyGCType.verifyCollection(TestVerifyGCType.java:196)
	at gc.g1.TestVerifyGCType.testYoungEvacFail(TestVerifyGCType.java:134)
	at gc.g1.TestVerifyGCType.main(TestVerifyGCType.java:57)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:312)
	at java.base/java.lang.Thread.run(Thread.java:1623)

Looks like this is same as JDK-8298215 which is already fixed. I guess the branch is not up-to-date and doesn't have the required fix, which is why this test failed. I think the failure can be ignored.

@ashu-mehra
Copy link
Contributor Author

/sponsor

@openjdk
Copy link

openjdk bot commented Jan 5, 2023

@ashu-mehra Only Committers are allowed to sponsor changes.

@ashu-mehra
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Jan 5, 2023
@openjdk
Copy link

openjdk bot commented Jan 5, 2023

@ashu-mehra
Your change (at version 5684e67) is now ready to be sponsored by a Committer.

@calvinccheung
Copy link
Member

There is a test failure on macos-x64 not related to the changes in this PR. The test test/hotspot/jtreg/gc/g1/TestVerifyGCType.java fails at:

java.lang.RuntimeException: Missing expected verification pattern Verifying After GC for: Pause Young (Prepare Mixed): expected true, was false
	at jdk.test.lib.Asserts.fail(Asserts.java:594)
	at jdk.test.lib.Asserts.assertTrue(Asserts.java:486)
	at gc.g1.TestVerifyGCType.verifyType(TestVerifyGCType.java:201)
	at gc.g1.TestVerifyGCType.verifyCollection(TestVerifyGCType.java:196)
	at gc.g1.TestVerifyGCType.testYoungEvacFail(TestVerifyGCType.java:134)
	at gc.g1.TestVerifyGCType.main(TestVerifyGCType.java:57)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:312)
	at java.base/java.lang.Thread.run(Thread.java:1623)

Looks like this is same as JDK-8298215 which is already fixed. I guess the branch is not up-to-date and doesn't have the required fix, which is why this test failed. I think the failure can be ignored.

Yes, if your repo doesn't contain the fix for JDK-8298215, the failure could be ignored.

@calvinccheung
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Jan 5, 2023

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

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 sponsor Pull request is ready to be sponsored labels Jan 5, 2023
@openjdk
Copy link

openjdk bot commented Jan 5, 2023

@calvinccheung @ashu-mehra Pushed as commit be64bf8.

💡 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 4 testing:

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

@ashu-mehra ashu-mehra deleted the JDK-8299329 branch February 7, 2023 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

5 participants