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

JDK-8320005 : Allow loading of shared objects with .a extension on AIX #16604

Closed
wants to merge 46 commits into from

Conversation

suchismith1993
Copy link
Contributor

@suchismith1993 suchismith1993 commented Nov 10, 2023

J2SE agent does not start and throws error when it tries to find the shared library ibm_16_am.
After searching for ibm_16_am.so ,the jvm agent throws and error as dll_load fails.It fails to identify the shared library ibm_16_am.a shared archive file on AIX.
Hence we are providing a function which will additionally search for .a file on AIX ,when the search for .so file fails.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8320005: Allow loading of shared objects with .a extension on AIX (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 16604

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 10, 2023

👋 Welcome back suchismith1993! 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 Nov 10, 2023

@suchismith1993 The following labels will be automatically applied to this pull request:

  • hotspot
  • serviceability

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org hotspot hotspot-dev@openjdk.org labels Nov 10, 2023
@suchismith1993 suchismith1993 changed the title Add support for .a extension in jvm agent. JDK-8320005 : Add support for .a extension in jvm agent. Nov 14, 2023
@suchismith1993 suchismith1993 changed the title JDK-8320005 : Add support for .a extension in jvm agent. JDK-8320005 : Native library suffix impact on hotspot code in AIX. Nov 14, 2023
@openjdk
Copy link

openjdk bot commented Nov 22, 2023

@suchismith1993 This pull request has not yet been marked as ready for integration.

@suchismith1993 suchismith1993 changed the title JDK-8320005 : Native library suffix impact on hotspot code in AIX. JDK-8320005 : Native library suffix impact on hotspot code in AIX Nov 22, 2023
@suchismith1993 suchismith1993 marked this pull request as ready for review November 22, 2023 16:15
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 22, 2023
@tstuefe
Copy link
Member

tstuefe commented Nov 22, 2023

Hi, is this patch meant for review already? If yes, could you please describe the problem you fix, and how you fix it? If no, I suggest working on it in draft state till its ready for review.

@suchismith1993
Copy link
Contributor Author

Hi, is this patch meant for review already? If yes, could you please describe the problem you fix, and how you fix it? If no, I suggest working on it in draft state till its ready for review.

I have updated the description. Let me know if anything is missing

Copy link
Member

@offamitkumar offamitkumar left a comment

Choose a reason for hiding this comment

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

some nits you might want to consider.

Comment on lines 3063 to 3064
//Replaces provided path with alternate path for the given file,if it doesnt exist.
//For AIX,this replaces .so with .a.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
//Replaces provided path with alternate path for the given file,if it doesnt exist.
//For AIX,this replaces .so with .a.
// Replaces the specified path with an alternative path for the given file if the original path doesn't exist.
// For AIX, this replaces extension from ".so" to ".a".


//Replaces provided path with alternate path for the given file,if it doesnt exist.
//For AIX,this replaces .so with .a.
void os::Aix::mapAlternateName(char* buffer, const char *extension) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
void os::Aix::mapAlternateName(char* buffer, const char *extension) {
void os::Aix::map_alternate_name(char* buffer, const char *extension) {

Comment on lines 180 to 181
// Provide alternate path name,if file does not exist.
static void mapAlternateName(char* buffer, const char *extension);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Provide alternate path name,if file does not exist.
static void mapAlternateName(char* buffer, const char *extension);
// Provides alternate path name, if file does not exist.
static void map_alternate_name(char* buffer, const char *extension);

@offamitkumar
Copy link
Member

Also are you planning to close this one : #16490 ? JBS issue is already closed.

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

A couple of comments.

First, if you always want to look for libfoo.a if you can't find libfoo.so then maybe that should be handled as the os::dll_load level? Otherwisae it is not clear why this is something you only do for agents. ?/

Second, the amount of AIX-specific code in the shared jvmtiAgent.cpp now seems unreasonable. As I think @tstuefe mentioned in another PR perhaps it is time to find better abstractions here to hide all these AIX specific quirks?

end = end - 1;
}
buffer[end] = '\0';
strcat(buffer, extension);
Copy link
Member

Choose a reason for hiding this comment

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

At some point you need to check the length of extension won't overflow buffer.

Copy link
Member

@tstuefe tstuefe left a comment

Choose a reason for hiding this comment

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

I'm not a big fan of this approach. We accumulate more and more "#ifdef AIX" in shared code because of many recent AIX additions. No other platform has such a large ifdef footprint in shared code.

I argue that all of this should be handled inside os_aix.cpp and not leak out into the external space:

If .a is a valid shared object format on AIX, this should be handled in os::dll_load(), and be done for all shared objects. If not, why do we try to load a static archive via dlload in this case but not in other cases?

If this is needed in shared code, the string replacement function should be a generic utility function for all platforms, and it should be tested with a small gtest. A gtest would have likely uncovered the buffer overflow too.

unsigned long end = strlen(buffer);
while (end > 0 && buffer[end] != '.') {
end = end - 1;
}
Copy link
Member

@tstuefe tstuefe Nov 23, 2023

Choose a reason for hiding this comment

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

Use strrchr.

Copy link
Member

@tstuefe tstuefe Nov 23, 2023

Choose a reason for hiding this comment

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

Pls handle the case where the string contains no dot.

}
buffer[end] = '\0';
strcat(buffer, extension);
}
Copy link
Member

Choose a reason for hiding this comment

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

This is a buffer overrun waiting to happen if replacement is larger than original extension.

src/hotspot/os/aix/os_aix.cpp Outdated Show resolved Hide resolved
@suchismith1993
Copy link
Contributor Author

#16490

The JBS issue with respect to that has been closed. Need to check if that PR is required. Currently putting it on hold.

@offamitkumar
Copy link
Member

The JBS issue with respect to that has been closed. Need to check if that PR is required. Currently putting it on hold.

This response on the issue suggest otherwise:

<S12Y triage team>: The JDK does not support dynamically loaded archive files (.a files) and there are no plans to add this support. Closing as will not fix

@suchismith1993
Copy link
Contributor Author

If .a is a valid shared object format on AIX, this should be handled in os::dll_load(), and be done for all shared objects. If not, why do we try to load a static archive via dlload in this case but not in other cases?

In AIX, we have shared objects with .a extension and also static archives with .a extension.I think in other platforms the format for shared objects is fixed? . In that case does this become specific to AIX?

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Feb 27, 2024
@openjdk
Copy link

openjdk bot commented Feb 27, 2024

@suchismith1993
Your change (at version 5791458) is now ready to be sponsored by a Committer.

// Shared object in .so format dont have braces, hence they get removed for archives with members.
if (result == nullptr && pointer_to_dot != nullptr && strcmp(pointer_to_dot, old_extension) == 0) {
snprintf(pointer_to_dot, sizeof(old_extension), "%s", new_extension);
result = dll_load_library(file_path, ebuf, ebuflen);
Copy link
Contributor

Choose a reason for hiding this comment

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

You should have adapted the indentation, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which indentation ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh! to reduce the spaces

Copy link
Contributor Author

@suchismith1993 suchismith1993 Feb 27, 2024

Choose a reason for hiding this comment

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

@TheRealMDoerr adapted

@openjdk openjdk bot removed the sponsor Pull request is ready to be sponsored label Feb 27, 2024
@suchismith1993
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Feb 27, 2024
@openjdk
Copy link

openjdk bot commented Feb 27, 2024

@suchismith1993
Your change (at version 5509044) is now ready to be sponsored by a Committer.

@TheRealMDoerr
Copy link
Contributor

/sponsor

@openjdk
Copy link

openjdk bot commented Feb 27, 2024

Going to push as commit e85355a.
Since your change was applied there have been 509 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 Feb 27, 2024
@openjdk openjdk bot closed this Feb 27, 2024
@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 Feb 27, 2024
@openjdk
Copy link

openjdk bot commented Feb 27, 2024

@TheRealMDoerr @suchismith1993 Pushed as commit e85355a.

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

@suchismith1993
Copy link
Contributor Author

/backport jdk21u

@openjdk
Copy link

openjdk bot commented Mar 5, 2024

@suchismith1993 the backport was successfully created on the branch backport-suchismith1993-e85355ad in my personal fork of openjdk/jdk21u. To create a pull request with this backport targeting openjdk/jdk21u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit e85355ad from the openjdk/jdk repository.

The commit being backported was authored by Suchismith Roy on 27 Feb 2024 and was reviewed by Amit Kumar, Thomas Stuefe, Joachim Kern and Martin Doerr.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u:

$ git fetch https://github.com/openjdk-bots/jdk21u.git backport-suchismith1993-e85355ad:backport-suchismith1993-e85355ad
$ git checkout backport-suchismith1993-e85355ad
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u.git backport-suchismith1993-e85355ad

⚠️ @suchismith1993 You are not yet a collaborator in my fork openjdk-bots/jdk21u. An invite will be sent out and you need to accept it before you can proceed.

@TheRealMDoerr
Copy link
Contributor

TheRealMDoerr commented Mar 5, 2024

jdk21u is only open for critical backports and requires special approval. Please backport it to jdk21u-dev.
What about jdk22u?
/backport commands should be used in commits, not in closed PRs.
Not sure if it works without Committer privileges.

@magicus
Copy link
Member

magicus commented Mar 5, 2024

@TheRealMDoerr FYI, /backport works in PRs as well as commits since some time ago... In fact, I would recommend it as the better way to create a backport, now that it exists.

@suchismith1993
Copy link
Contributor Author

/backport jdk22u

@openjdk
Copy link

openjdk bot commented Mar 6, 2024

@suchismith1993 the backport was successfully created on the branch backport-suchismith1993-e85355ad in my personal fork of openjdk/jdk22u. To create a pull request with this backport targeting openjdk/jdk22u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit e85355ad from the openjdk/jdk repository.

The commit being backported was authored by Suchismith Roy on 27 Feb 2024 and was reviewed by Amit Kumar, Thomas Stuefe, Joachim Kern and Martin Doerr.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk22u:

$ git fetch https://github.com/openjdk-bots/jdk22u.git backport-suchismith1993-e85355ad:backport-suchismith1993-e85355ad
$ git checkout backport-suchismith1993-e85355ad
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk22u.git backport-suchismith1993-e85355ad

⚠️ @suchismith1993 You are not yet a collaborator in my fork openjdk-bots/jdk22u. An invite will be sent out and you need to accept it before you can proceed.

@suchismith1993
Copy link
Contributor Author

/backport jdk21u-dev

@suchismith1993
Copy link
Contributor Author

/backport jdk11u-dev

@suchismith1993
Copy link
Contributor Author

/backport jdk17u-dev

@suchismith1993
Copy link
Contributor Author

/backport jdk8u-dev

@openjdk
Copy link

openjdk bot commented Mar 6, 2024

@suchismith1993 the backport was successfully created on the branch backport-suchismith1993-e85355ad in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit e85355ad from the openjdk/jdk repository.

The commit being backported was authored by Suchismith Roy on 27 Feb 2024 and was reviewed by Amit Kumar, Thomas Stuefe, Joachim Kern and Martin Doerr.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-suchismith1993-e85355ad:backport-suchismith1993-e85355ad
$ git checkout backport-suchismith1993-e85355ad
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-suchismith1993-e85355ad

⚠️ @suchismith1993 You are not yet a collaborator in my fork openjdk-bots/jdk21u-dev. An invite will be sent out and you need to accept it before you can proceed.

@openjdk
Copy link

openjdk bot commented Mar 6, 2024

@suchismith1993 Could not automatically backport e85355ad to openjdk/jdk11u-dev due to conflicts in the following files:

  • src/hotspot/os/aix/os_aix.cpp

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk11u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk11u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-suchismith1993-e85355ad

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git e85355ada4ac1061c49ee9f1247d37a437c7b5ab

# Backport the commit
$ git cherry-pick --no-commit e85355ada4ac1061c49ee9f1247d37a437c7b5ab
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport e85355ada4ac1061c49ee9f1247d37a437c7b5ab'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk11u-dev with the title Backport e85355ada4ac1061c49ee9f1247d37a437c7b5ab.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit e85355ad from the openjdk/jdk repository.

The commit being backported was authored by Suchismith Roy on 27 Feb 2024 and was reviewed by Amit Kumar, Thomas Stuefe, Joachim Kern and Martin Doerr.

Thanks!

@openjdk
Copy link

openjdk bot commented Mar 6, 2024

@suchismith1993 Could not automatically backport e85355ad to openjdk/jdk17u-dev due to conflicts in the following files:

  • src/hotspot/os/aix/os_aix.cpp

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk17u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk17u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-suchismith1993-e85355ad

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git e85355ada4ac1061c49ee9f1247d37a437c7b5ab

# Backport the commit
$ git cherry-pick --no-commit e85355ada4ac1061c49ee9f1247d37a437c7b5ab
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport e85355ada4ac1061c49ee9f1247d37a437c7b5ab'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk17u-dev with the title Backport e85355ada4ac1061c49ee9f1247d37a437c7b5ab.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit e85355ad from the openjdk/jdk repository.

The commit being backported was authored by Suchismith Roy on 27 Feb 2024 and was reviewed by Amit Kumar, Thomas Stuefe, Joachim Kern and Martin Doerr.

Thanks!

@openjdk
Copy link

openjdk bot commented Mar 6, 2024

@suchismith1993 Could not automatically backport e85355ad to openjdk/jdk8u-dev due to conflicts in the following files:

  • src/hotspot/os/aix/os_aix.cpp

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk8u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk8u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-suchismith1993-e85355ad

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git e85355ada4ac1061c49ee9f1247d37a437c7b5ab

# Backport the commit
$ git cherry-pick --no-commit e85355ada4ac1061c49ee9f1247d37a437c7b5ab
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport e85355ada4ac1061c49ee9f1247d37a437c7b5ab'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk8u-dev with the title Backport e85355ada4ac1061c49ee9f1247d37a437c7b5ab.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit e85355ad from the openjdk/jdk repository.

The commit being backported was authored by Suchismith Roy on 27 Feb 2024 and was reviewed by Amit Kumar, Thomas Stuefe, Joachim Kern and Martin Doerr.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

8 participants