RFR: 8277444: Race condition on Instrumentation.retransformClasses() and class linking

Evgeny Astigeevich eastigeevich at openjdk.org
Wed Aug 20 15:46:46 UTC 2025


On Wed, 20 Aug 2025 15:36:14 GMT, Evgeny Astigeevich <eastigeevich at openjdk.org> wrote:

> There is a race between `JvmtiClassFileReconstituter::copy_bytecodes` and `InstanceKlass::link_class_impl`.  `InstanceKlass::link_class_impl` can be rewriting bytecodes. `JvmtiClassFileReconstituter::copy_bytecodes` will not restore them to the original ones because the flag `rewritten` is `false`. This will result in invalid bytecode.
> 
> This PR adds a lock (`init_lock`) to the `copy_bytecodes` method to prevent reading bytecodes while they are being rewritten during class linking.
> 
> Tested fastdebug and release builds: Linux x86_64 and arm64
> - The reproducer from JDK-8277444 passed.
> - Tier1 - tier3 passed.

Hi @coleenp,
Could you please take a look?

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

PR Comment: https://git.openjdk.org/jdk/pull/26863#issuecomment-3206937011


More information about the hotspot-dev mailing list