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

8303489: Add a test to verify classes in vmStruct have unique vtables #12820

Closed
wants to merge 3 commits into from

Conversation

alexmenkov
Copy link

@alexmenkov alexmenkov commented Mar 2, 2023

Unique vtables for classes in vmStruct data is a requirement for SA to correctly detect hotspot classes.
The fix adds test to verify this requirement.

The test fails as expected on Windows if VM is built without RTTI (see JDK-8302817)


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-8303489: Add a test to verify classes in vmStruct have unique vtables

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 12820

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 2, 2023

👋 Welcome back amenkov! 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 Mar 2, 2023
@openjdk
Copy link

openjdk bot commented Mar 2, 2023

@alexmenkov 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 Mar 2, 2023
@mlbridge
Copy link

mlbridge bot commented Mar 2, 2023

Webrevs

}
}

if (vtable == null && t.getSuperclass() != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why only log if there is no superclass?

Copy link
Author

@alexmenkov alexmenkov Mar 2, 2023

Choose a reason for hiding this comment

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

vmStruct contains a lot of entries which should have vtable == null
I added logging of some stats to the test, on win-x64-fastdebug it reports:
total: 861, no vtable: 503, no_vtable_with_super: 24
if test would log everything with no vtable, test log is truncated

Copy link
Contributor

Choose a reason for hiding this comment

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

In that case is it worth listing the "no vtable" classes that have a superclass? Are they somehow more interesting than those without a superclass?

Copy link
Author

Choose a reason for hiding this comment

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

If superclass is set then it's the type which describes VM class (but some JM classes have super == null)
Maybe the test should report all Types with CInt: false, CStr: false, JPrimitive: false, Oop: false, Ptr: false
Looks like these entries correspond declare_toplevel_type/declare_type in vmStruct

Copy link
Author

Choose a reason for hiding this comment

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

Updated criteria to log classes without vtable

Comment on lines 114 to 118
+ ", CInt: " + t.isCIntegerType()
+ ", CStr: " + t.isCStringType()
+ ", JPrimitive: " + t.isJavaPrimitiveType()
+ ", Oop: " + t.isOopType()
+ ", Ptr: " + t.isPointerType());
Copy link
Contributor

Choose a reason for hiding this comment

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

It appears that these always print "false". Are they worth having?

Copy link
Author

Choose a reason for hiding this comment

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

It reports all available info about the Type. As these are "suspicious" types I think it make sense to provide more info

Copy link
Author

Choose a reason for hiding this comment

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

removed this property as by the updated condition logged classes have all "false"

test/hotspot/jtreg/serviceability/sa/UniqueVtableTest.java Outdated Show resolved Hide resolved
test/hotspot/jtreg/serviceability/sa/UniqueVtableTest.java Outdated Show resolved Hide resolved
@alexmenkov
Copy link
Author

/issue JDK-8303489

@openjdk openjdk bot changed the title 8303489: Add a test to verify classes in vmStruct have unuque vtables 8303489: Add a test to verify classes in vmStruct have unique vtables Mar 2, 2023
@openjdk
Copy link

openjdk bot commented Mar 2, 2023

@alexmenkov This issue is referenced in the PR title - it will now be updated.

}
}

if (vtable == null && t.getSuperclass() != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

In that case is it worth listing the "no vtable" classes that have a superclass? Are they somehow more interesting than those without a superclass?

Iterator<Type> it = agent.getTypeDataBase().getTypes();
int dupsFound = 0;
// agent.getTypeDataBase() returns HotSpotTypeDataBase (extends BasicTypeDataBase)
BasicTypeDataBase typeDB = (BasicTypeDataBase)(agent.getTypeDataBase());
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the cast is needed.

Copy link
Author

Choose a reason for hiding this comment

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

agent.getTypeDataBase() returns TypeDataBase, we need BasicTypeDataBase

Copy link
Contributor

Choose a reason for hiding this comment

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

Your comment seems to indicate otherwise, although I think what you meant is that the declared return type for agent.getTypeDataBase() is TypeDataBase, but it actually returns an object of type HotSpotTypeDataBase, which is a subclass of BasicTypeDataBase. You should make that more clear.

Copy link
Author

Choose a reason for hiding this comment

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

Updated the comment. Hope it's clearer now

if (vtable != null) {
List<Type> typeList = types.get(vtable);
no_vtable++;
Copy link
Contributor

Choose a reason for hiding this comment

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

no_vtable is actually tracking the number of Types with a vtable.

Copy link
Author

Choose a reason for hiding this comment

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

Changed reported stats

Copy link
Contributor

@plummercj plummercj 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 for adding this.

@openjdk
Copy link

openjdk bot commented Mar 3, 2023

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

8303489: Add a test to verify classes in vmStruct have unique vtables

Reviewed-by: cjplummer, sspitsyn

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

  • 21a6ab1: 8303799: [BACKOUT] JDK-8302801 Remove fdlibm C sources
  • 5fa9bd4: 8302189: Mark assertion failures noreturn
  • 9b10c69: 8303622: JFR: Missing message with Objects.requireNonNull
  • d729824: 8286781: Replace the deprecated/obsolete gethostbyname and inet_addr calls
  • 5f1108f: 8303151: DCmd framework cleanups
  • 32f4d8b: 8303681: JFR: RemoteRecordingStream::setMaxAge() should accept null
  • 9f9d678: 8302791: Add specific ClassLoader object to Proxy IllegalArgumentException message
  • b5b5cba: 8302801: Remove fdlibm C sources
  • 4d4eade: 8302452: [JVMCI] Export _poly1305_processBlocks, JfrThreadLocal fields to JVMCI compiler.
  • f1f4e1d: 6453901: (cal) clean up sun.util.calendar classes
  • ... and 176 more: https://git.openjdk.org/jdk/compare/180b94c73e9ad17d57650d4c985d4104289052a9...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 Mar 3, 2023
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

@alexmenkov
Copy link
Author

/integrate

@openjdk
Copy link

openjdk bot commented Mar 9, 2023

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

  • 595645c: 8294959: java.base java.lang.Module uses ASM to load module-info.class
  • 68b5eef: 8303334: Further improve liveness/remembered set verification for G1
  • 3227b49: 8303760: Visual Studio should use the primary variant in the IDE
  • cdcf5c1: 8303702: Provide ThreadFactory to create platform/virtual threads for com/sun/jdi tests
  • 4655b79: 8294982: Implementation of Classfile API
  • 1e9942a: 8303881: Mixed, minor cleanup in jdk.compiler
  • 7e01534: 8303467: Serial: Refactor reference processor
  • 713def0: 8303105: LoopRangeStrideTest fails IR verification on x86
  • 34a9246: 8274264: Not all of G1 young collection verification honors the verification type
  • a7e308a: 8303576: addIdentitiesToKeystore in KeystoreImpl.m needs CFRelease call in early potential CHECK_NULL return
  • ... and 205 more: https://git.openjdk.org/jdk/compare/180b94c73e9ad17d57650d4c985d4104289052a9...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Mar 9, 2023

@alexmenkov Pushed as commit f9aadb9.

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

@alexmenkov alexmenkov deleted the sa_vtable branch March 9, 2023 19:21
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
3 participants