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
8301564: Non-C-heap allocated ResourceHashtable keys and values must have trivial destructor #12355
8301564: Non-C-heap allocated ResourceHashtable keys and values must have trivial destructor #12355
Conversation
…have trivial destructor
👋 Welcome back iklam! A progress list of the required criteria for merging this PR into |
Webrevs
|
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 good. Glad there weren't more hashtables breaking this assumption.
@@ -112,7 +112,7 @@ class ClassLoaderStatsClosure : public CLDClosure { | |||
} | |||
|
|||
typedef ResourceHashtable<oop, ClassLoaderStats, | |||
256, AnyObj::RESOURCE_AREA, mtInternal, | |||
256, AnyObj::C_HEAP, mtInternal, |
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.
There's an mtStatistics NMT category, can you use that for this? and the instance below?
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.
Fixed.
@iklam 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 no new commits pushed to the ➡️ To integrate this PR with the above commit message to the |
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.
This looks good, thanks.
I'll put this here for posterity: we discussed changing ResourceHashtable
to always call the destructor of the key and value (sketch here). That would allow using K
and V
with non-trivial destructors as well. But, this discussion didn't reach a conclusion yet (in particular, there were some doubts expressed over whether a container should be calling destructors at all).
In the mean time, this patch improves upon the status quo.
Thanks @JornVernee and @coleenp for the review. |
Going to push as commit 04278e6.
Your commit was automatically rebased without conflicts. |
To ensure we don't have memory leaks or other more serious memory management bugs, I added static asserts to check that the
K
andV
types forResourceHashtableBase
must have trivial destructors if the table is notC_HEAP
allocated. Thanks to @JornVernee for the original assert code.The asserts actually found a problem with
ClassLoaderStatsClosure::StatsTable
. The space used by theoop
in the freed hashtable may be trashed when-XX:+CheckUnhandledOops
is enabled, so live objects that reuse the same space may be corrupted. (I tried but couldn't get it to fail).I also had to change
CodeBuffer::SharedTrampolineRequests
because it'sV
type isLinkListImpl<int>
, which has a non-trivial destructor. (Note: in this case, the destructor doesn't do anything; we can probably make it go away with C++-20. See https://stackoverflow.com/questions/40094871/sfinae-away-a-destructor)Testing with tier1~4 + builds-tier5
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12355/head:pull/12355
$ git checkout pull/12355
Update a local copy of the PR:
$ git checkout pull/12355
$ git pull https://git.openjdk.org/jdk pull/12355/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 12355
View PR using the GUI difftool:
$ git pr show -t 12355
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12355.diff