RFR: 8355960: JvmtiAgentList::Iterator dtor double free with -fno-elide-constructors

Alex Menkov amenkov at openjdk.org
Wed Jul 2 01:55:48 UTC 2025


Currently jvmtiAgentList keeps agents in reversed order (new agents are added to the head of the list).
To restore original order JvmtiAgentList::Iterator uses GrowableArray allocated in heap.
Iterators for different agent types are returned by value, and the iterator class nas no custom copy ctor, so if the constructor not elides, GrowableArray is deallocated twice.

The fix updates jvmtiAgentList to keep agents in the original order, agents are added to the tail.
Iterator now needs only single pointer to next agent.
Additionally removed `JvmtiAgentList::Iterator::next() const` method (it looks very strange as `next()` is expected to change state of the iterator).

Testing: tier1..4,hs-tier5-svc

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

Commit messages:
 - fix

Changes: https://git.openjdk.org/jdk/pull/26083/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26083&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8355960
  Stats: 83 lines in 5 files changed: 27 ins; 28 del; 28 mod
  Patch: https://git.openjdk.org/jdk/pull/26083.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/26083/head:pull/26083

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


More information about the serviceability-dev mailing list