RFR: 8301564: Non-C-heap allocated ResourceHashtable keys and values must have trivial destructor [v3]

Ioi Lam iklam at openjdk.org
Thu Feb 2 17:22:01 UTC 2023


> To ensure we don't have memory leaks or other more serious memory management bugs, I added static asserts to check that the `K` and `V` types for `ResourceHashtableBase` must have trivial destructors if the table is not `C_HEAP` allocated. Thanks to @JornVernee for the original assert code.
> 
> The asserts actually found a problem with `ClassLoaderStatsClosure::StatsTable`. The space used by the `oop` 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's `V` type is `LinkListImpl<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

Ioi Lam has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:

 - Merge branch 'master' into 8301564-forbid-non-trivial-destructor-for-resourcehash-KV-types
 - @coleenp comments - use mtStatistics instead
 - fixed aarch64 and risvc64
 - fixed typo
 - Fixed ClassLoaderStatsClosure::StatsTable
 - 8301564: Non-C-heap allocated ResourceHashtable keys and values must have trivial destructor

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/12355/files
  - new: https://git.openjdk.org/jdk/pull/12355/files/915f058b..2421a75e

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=12355&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=12355&range=01-02

  Stats: 20095 lines in 935 files changed: 5641 ins; 3886 del; 10568 mod
  Patch: https://git.openjdk.org/jdk/pull/12355.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/12355/head:pull/12355

PR: https://git.openjdk.org/jdk/pull/12355


More information about the hotspot-dev mailing list