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

Serguei Spitsyn sspitsyn at openjdk.org
Thu Jul 3 02:04:46 UTC 2025


On Thu, 3 Jul 2025 01:17:56 GMT, Alex Menkov <amenkov at openjdk.org> wrote:

>> 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
>
> Alex Menkov has updated the pull request incrementally with one additional commit since the last revision:
> 
>   update

Changes requested by sspitsyn (Reviewer).

src/hotspot/share/prims/jvmtiAgentList.hpp line 30:

> 28: //#include "nmt/memTag.hpp"
> 29: #include "prims/jvmtiAgent.hpp"
> 30: //#include "utilities/growableArray.hpp"

Nit: You might want to remove unneeded headers. :)

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

PR Review: https://git.openjdk.org/jdk/pull/26083#pullrequestreview-2981271238
PR Review Comment: https://git.openjdk.org/jdk/pull/26083#discussion_r2181383291


More information about the serviceability-dev mailing list