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

8292202: modules_do is called without Module_lock #10291

Closed

Conversation

calvinccheung
Copy link
Member

@calvinccheung calvinccheung commented Sep 15, 2022

Please review this fix which involves:

  • acquire the Module_lock before calling modules_do;
  • move the call to ClassLoader::setup_module_search_path out of do_module;
  • save the module paths in a GrowableArray in do_module for calling ClassLoader::setup_module_search_path.

Passed tiers 1 - 3 testing.


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-8292202: modules_do is called without Module_lock

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10291

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 15, 2022

👋 Welcome back ccheung! 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.

@calvinccheung
Copy link
Member Author

/label add hotspot-runtime

@calvinccheung calvinccheung marked this pull request as ready for review September 15, 2022 18:03
@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Sep 15, 2022
@openjdk
Copy link

openjdk bot commented Sep 15, 2022

@calvinccheung
The hotspot-runtime label was successfully added.

@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 15, 2022
@mlbridge
Copy link

mlbridge bot commented Sep 15, 2022

Webrevs

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.

Looks good. A minor suggestion to simplify the code.

ClassLoader::setup_module_search_path(_current, path);
char* path_copy = NEW_RESOURCE_ARRAY(char, strlen(path) + 1);
strcpy(path_copy, path);
_module_paths->at_put_grow(_total_count++, path_copy);
Copy link
Member

Choose a reason for hiding this comment

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

You can use _module_paths->append() to avoid keeping the _total_count

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.
Thanks for your review.

@openjdk
Copy link

openjdk bot commented Sep 15, 2022

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

8292202: modules_do is called without Module_lock

Reviewed-by: iklam, coleenp

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:

  • 742bc04: 8294100: RISC-V: Move rt_call and xxx_move from SharedRuntime to MacroAssembler
  • 2283c32: 8294149: JMH 1.34 and later requires jopt-simple 5.0.4
  • 9f90eb0: 8294062: Improve parsing performance of j.l.c.MethodTypeDesc
  • c6be2cd: 8293156: Dcmd VM.classloaders fails to print the full hierarchy
  • 711e252: 8294039: Remove "Classpath" exception from java/awt tests
  • 27b8e2f: 8294038: Remove "Classpath" exception from javax/swing tests
  • e195897: 8294068: Unconditional and eager load of nio library since JDK-8264744
  • 84d7ff6: 8288129: Shenandoah: Skynet test crashed with iu + aggressive
  • 07afa3f: 8294110: compiler/uncommontrap/Decompile.java fails after JDK-8293798
  • 0746bcb: 8294083: RISC-V: Minimal build failed with --disable-precompiled-headers
  • ... and 29 more: https://git.openjdk.org/jdk/compare/4020ed53dd6e45cafa1d86432274700f0d4a67ca...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 Sep 15, 2022
Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

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

Looks great. Thanks for fixing this. Can you add in moduleEntry.cpp in both modules_do function an assert that the Module_lock is held. The other modules_do has the assert at a higher level so nothing will trigger it. The modules_do() that this calls now will not fail the assert.

@calvinccheung
Copy link
Member Author

Hi Coleen,

Thanks for your review.

I've added assert in moduleEntry.cpp as follows:

diff --git a/src/hotspot/share/classfile/moduleEntry.cpp b/src/hotspot/share/classfile/moduleEntry.cpp
index a85c8f41145..f12f63ba2e5 100644
--- a/src/hotspot/share/classfile/moduleEntry.cpp
+++ b/src/hotspot/share/classfile/moduleEntry.cpp
@@ -694,6 +694,7 @@ void ModuleEntryTable::modules_do(void f(ModuleEntry*)) {
   auto do_f = [&] (const SymbolHandle& key, ModuleEntry*& entry) {
     f(entry);
   };
+  assert_lock_strong(Module_lock);
   _table.iterate_all(do_f);
 }
 
@@ -701,6 +702,7 @@ void ModuleEntryTable::modules_do(ModuleClosure* closure) {
   auto do_f = [&] (const SymbolHandle& key, ModuleEntry*& entry) {
     closure->do_module(entry);
   };
+  assert_lock_strong(Module_lock);
   _table.iterate_all(do_f);
 }

I'll run some mach5 testing before integrating the fix.

Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

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

thanks!

@calvinccheung
Copy link
Member Author

Thanks @iklam and @coleenp.

/integrate

@openjdk
Copy link

openjdk bot commented Sep 22, 2022

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

  • 742bc04: 8294100: RISC-V: Move rt_call and xxx_move from SharedRuntime to MacroAssembler
  • 2283c32: 8294149: JMH 1.34 and later requires jopt-simple 5.0.4
  • 9f90eb0: 8294062: Improve parsing performance of j.l.c.MethodTypeDesc
  • c6be2cd: 8293156: Dcmd VM.classloaders fails to print the full hierarchy
  • 711e252: 8294039: Remove "Classpath" exception from java/awt tests
  • 27b8e2f: 8294038: Remove "Classpath" exception from javax/swing tests
  • e195897: 8294068: Unconditional and eager load of nio library since JDK-8264744
  • 84d7ff6: 8288129: Shenandoah: Skynet test crashed with iu + aggressive
  • 07afa3f: 8294110: compiler/uncommontrap/Decompile.java fails after JDK-8293798
  • 0746bcb: 8294083: RISC-V: Minimal build failed with --disable-precompiled-headers
  • ... and 29 more: https://git.openjdk.org/jdk/compare/4020ed53dd6e45cafa1d86432274700f0d4a67ca...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Sep 22, 2022

@calvinccheung Pushed as commit 47f233a.

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

@calvinccheung calvinccheung deleted the 8292202-modules_do branch September 22, 2022 03:51
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.

3 participants