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

8310874: Runthese30m crashes with klass should be in the placeholders during verification #14889

Closed
wants to merge 5 commits into from

Conversation

coleenp
Copy link
Contributor

@coleenp coleenp commented Jul 14, 2023

This is a better fix and cleanup to make placeholder use for non-parallel capable class loaders the same as the other sort of class loaders, and fixes potential problems with thread safety in the definer field of the PlaceholderEntry. It's not easy to backport, which is why I chose the other fix for this bug.
Tested with tier1-4 with and without injected LoaderConstrantTable::verify code.


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-8310874: Runthese30m crashes with klass should be in the placeholders during verification (Bug - P3)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14889

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

Using diff file

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

Webrev

Link to Webrev Comment

Sorry, something went wrong.

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 14, 2023

👋 Welcome back coleenp! 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 Jul 14, 2023

@coleenp 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 Jul 14, 2023
Comment on lines 328 to 330
if (definer_acquire() != nullptr) {
st->print(", definer ");
definer()->print_value_on(st);
definer_acquire()->print_value_on(st);
Copy link
Member

Choose a reason for hiding this comment

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

Ignoring whether we need acquire semantics at all for definer, you never need to issue two acquires like this. The first acquire performs any necessary memory synchronization related to the associated release. And if the definer could actually be changing concurrently at this point then your null check is ineffective.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since I added the acquire version, I wanted to remove the non-acquire version to avoid mistakes.

// If a class loader supports parallel classloading with AllowParallelDefineClass for parallel-capable class non-boot
// class loaders, handle parallel define requests. In this case, find_or_define_instance_class may return a different
// InstanceKlass, in which case the old k would be deallocated
k = find_or_define_instance_class(h_name, class_loader, k, CHECK_NULL);
Copy link
Member

Choose a reason for hiding this comment

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

Now that you call this for parallel-capable and non-parallel-capable loaders the comments preceding the definition of find_or_define_instance_class no longer make complete sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This comment is still true. non bootstrap parallel-capable class loaders might return a different k.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Edit. yes this comment repeats what find_or_define_instance_class already says later on, so doesn't really add anything here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What would make more sense is find_or_define_instance_class was renamed define_instance_class (which actually handled the AllowParallelDefine logic without bothering the caller about it).

Copy link
Contributor Author

@coleenp coleenp Jul 31, 2023

Choose a reason for hiding this comment

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

maybe not. It does return a 'k' and the comment explains why.

Copy link
Member

Choose a reason for hiding this comment

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

My point is that this:

// If a class loader supports parallel classloading handle parallel define requests.
// find_or_define_instance_class may return a different InstanceKlass
InstanceKlass* SystemDictionary::find_or_define_instance_class(Symbol* class_name, Handle class_loader,
                                                               InstanceKlass* k, TRAPS) {

makes it seem like this method is only for parallel-capable loaders when that is no longer true. The same goes for the large comment block ahead of find_or_define_helper. These methods do not document how they work for non-parallel-capable loaders.

@coleenp coleenp marked this pull request as ready for review August 1, 2023 17:50
@coleenp
Copy link
Contributor Author

coleenp commented Aug 1, 2023

Opening for review with @dholmes-ora comments on the Draft PR.

@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 1, 2023
@mlbridge
Copy link

mlbridge bot commented Aug 1, 2023

Webrevs

@coleenp
Copy link
Contributor Author

coleenp commented Aug 18, 2023

Remerged with master because this PR got old and forgotten. It still passes all the tests and it is ready for review.

@coleenp
Copy link
Contributor Author

coleenp commented Aug 23, 2023

@iklam pointed out to me privately that SystemDictionary::load_instance_class has the same pattern and the placeholder tokens are not consistent here either. For LOAD_INSTANCE (ie loading), we only take a placeholder token for the bootstrap loader and for non-parallel capable class loaders, and NOT for parallel capable class loaders.
For some reason, I can't provoke this failure with a LoaderConstraintsTable::verify() but it appears possible.
The verify in LoaderConstraintsTable is trying to make sure there are no InstanceKlass in the table that aren't loaded or in the process of being loaded. It doesn't do a very good job. If there were such InstanceKlass though, the memory would be reclaimed and the access to that InstanceKlass (ie, if there were an error) would crash. So the verification code doesn't really find anything useful the way it's written. I'm going to go back to my first patch that removes this.

@coleenp coleenp closed this Aug 23, 2023
@coleenp coleenp deleted the placeholder-bug branch August 23, 2023 12:05
@coleenp
Copy link
Contributor Author

coleenp commented Aug 23, 2023

FYI, I like this patch for other reasons but not for fixing this bug.

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 rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

None yet

2 participants