The problem here is that after method redefinition we still retain an MTD 
object pointing to the old `Method*`. When this old method is eventually GCed 
we end up with a dangling pointer, which when dereferenced leads potentially to 
a crash if this area of metaspace has been overwritten by something else.

The solution is to remove pointers to redefined Methods and Klasses from the 
training data after redefinition and preventing the re-addition of those again. 
I also added some verification to check the training data stays clean.

This change will go in after #30517 is pushed.

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

Commit messages:
 - Cleanup TD after redefinition

Changes: https://git.openjdk.org/jdk/pull/30540/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=30540&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8379819
  Stats: 53 lines in 4 files changed: 38 ins; 10 del; 5 mod
  Patch: https://git.openjdk.org/jdk/pull/30540.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/30540/head:pull/30540

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

Reply via email to