Skip to content

Prevent deadlock in java.base creation #19458

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

Merged
merged 1 commit into from
May 10, 2024
Merged

Conversation

tajila
Copy link
Contributor

@tajila tajila commented May 7, 2024

Thread 1 creates java.base:

  • acquires module (classLoaderModuleAndLocationMutex) mutex
  • acquires class mutex (classTableMutex) to update all bootstrap classes

Thread 2 loads a class

  • aquires class mutex
  • acquire module mutex to search for class location

There is a scenario where Thread 1 acquires module mutex, then thread 2 acquires class mutex. Thread 1 cannot complete creating java.base because it needs the class mutex and Thread 2 cannot complete class loading because it needs the module mutex.

Related: #19439

Proposed solution is for Thread 1 to acquire the class mutex first if it is known that it will be needed.

Thread 1 creates java.base:
- acquires module (classLoaderModuleAndLocationMutex) mutex
- acquires class mutex (classTableMutex) to update all bootstrap classes

Thread 2 loads a class
- aquires class mutex
- acquire module mutex to search for class location

There is a scenario where Thread 1 acquires module mutex, then thread 2
acquires class mutex. Thread 1 cannot complete creating java.base
because it needs the class mutex and Thread 2 cannot complete class
loading because it needs the module mutex.

Proposed solution is for Thread 1 to acquire the class mutex first if
it is known that it will be needed.

Related: eclipse-openj9#19439

Signed-off-by: tajila <[email protected]>
@tajila
Copy link
Contributor Author

tajila commented May 7, 2024

jenkins test sanity alinux64 jdk23

@tajila
Copy link
Contributor Author

tajila commented May 7, 2024

jenkins test sanity alinux64 jdknext

@tajila
Copy link
Contributor Author

tajila commented May 9, 2024

@gacholio please review

@gacholio gacholio merged commit 7acb77c into eclipse-openj9:master May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants