On Wed, 28 Oct 2026 14:45:02 GMT, Timofei Pushkin <[email protected]> wrote:
> Fixes leaks I could identify on `Agent_OnAttach` failure paths. > > In `libinstrument`: > - the changes to `Agent_OnAttach` are the important ones, while > `DEF_Agent_OnLoad` and `loadAgent` are updated for hygiene and uniformity > (when they fail the process gets killed anyway) > - besides implementing a proper cleanup (the "Improve failure cleanup in > libinstrument" commit), I also reordered a few agent initialization steps to > not create the JVM TI environment and change the classpath before the > provided JAR is validated (the "Reorder blocks to minimize unrecoverable > changes" commit) > > The HotSpot change is adding a destructor to `JvmtiAgent` for the `delete` in > `JvmtiAgentList::load_agent` executed when `Agent_OnAttach` fails. > > Tested by running `jdk_instrument`, `svc_tools`, `vmTestbase_nsk_aod`, > `hotspot/vmTestbase/nsk/jvmti/AttachOnDemand`, > `hotspot/serviceability/jvmti/RedefineClasse`. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). This pull request has now been integrated. Changeset: 4f116f94 Author: Timofei Pushkin <[email protected]> Committer: David Holmes <[email protected]> URL: https://git.openjdk.org/jdk/commit/4f116f94478d2ea4ab298acf95280f8341ab96ba Stats: 510 lines in 5 files changed: 206 ins; 177 del; 127 mod 8396046: Leaks after failing to attach a JVM TI agent Reviewed-by: dholmes, sspitsyn ------------- PR: https://git.openjdk.org/jdk/pull/33608
