-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8329850: [AIX] Allow loading of different members of same shared library archive #18676
Conversation
👋 Welcome back jkern! A progress list of the required criteria for merging this PR into |
@JoKern65 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:
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 273 new commits pushed to the
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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@TheRealMDoerr, @MBaesken, @tstuefe) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
while (*substr) { | ||
hash = (hash << 5) - hash + (unsigned long)*substr++; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should work in practical cases, but what if a hash collision occurs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How likely is a hash collision? My first thought was to store the member string in an additional array. But there is no length limitation. So I cannot just add an char array of e.g. 20 chars, but have to use a pointer to an external dynamically loaded memory holding the string. I came to the conclusion that a hash is much more elegant with a neglectable small risk of a hash collision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess extremely unlikely. But if it happens, it will be an extremely annoying problem.
I'd probably use strdup, but let's hear what other reviewers think.
@tstuefe Would you be so kind and please take a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for fixing it and for the update!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay to me.
But I think it would be really beneficial to have a (jtreg) test for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a brief skim over this change.
This would be a lot simpler had we just used string comparison instead of using inodes for equality. Then, we could have just used file name plus member name as key in the table.
Remind me again, why do we compare inodes instead of just file names?
src/hotspot/os/aix/porting_aix.cpp
Outdated
unsigned i = 0; | ||
TableLocker lock; | ||
// check if library belonging to filename is already loaded. | ||
// If yes use stored handle from previous ::dlopen() and increase refcount | ||
for (i = 0; i < g_handletable_used; i++) { | ||
if ((p_handletable + i)->handle && | ||
(p_handletable + i)->inode == libstat.st_ino && | ||
(p_handletable + i)->devid == libstat.st_dev) { | ||
(p_handletable + i)->devid == libstat.st_dev && | ||
(((p_handletable + i)->member == member) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this ever fires (wildly unlikely), its a bug. You are comparing a stack address with something that lives in C heap right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I discussed this with Martin. The meaning of the line is: Check if both are nullptr.
My original implementation was:
(((p_handletable + i)->member == nullptr && member == nullptr) ||
Martin favoured the shorter version above which will have the same result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, to me, not obvious where the member is reset. We delete it, but don't set the pointer to NULL.So, its not obvious that entry->member could not point to a former stale c heap address.
In any case, I prefer the cleanly written out logic. The generated code will be the same anyway, so this brevity just obfuscates your intent and confuses casual readers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Back to the roots.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that Thomas' point is that member = nullptr;
is missing after the free
operation. I agree with that.
One simplification, maybe: Is there some limitation as to the length of the member name, and if yes, reasonably short? If yes, just make the member name inline ion the table entry and save the malloc/strdup and free. |
I marked this already (see above). Unfortunately there seems to be no length limitation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Back to the roots" doesn't address the missing member = nullptr;
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/integrate |
/sponsor |
Going to push as commit cfd19f0.
Your commit was automatically rebased without conflicts. |
@TheRealMDoerr @JoKern65 Pushed as commit cfd19f0. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
With JDK-8320890 we introduced the capability not to load shared libraries twice if the application wants to do that. Instead we just rise a ref counter. Unfortunately this also suppresses the loading of a second member of a shared library.
This fix introduces an additionally stored hash value for each loaded member and only suppresses duplicate loading if the same member is loaded twice.
If a shared library has no member a hash value of 0 is used to make the code orthogonal.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18676/head:pull/18676
$ git checkout pull/18676
Update a local copy of the PR:
$ git checkout pull/18676
$ git pull https://git.openjdk.org/jdk.git pull/18676/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 18676
View PR using the GUI difftool:
$ git pr show -t 18676
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18676.diff
Webrev
Link to Webrev Comment