RFR: 8277444: Race condition on Instrumentation.retransformClasses() and class linking [v2]
Evgeny Astigeevich
eastigeevich at openjdk.org
Wed Aug 20 17:31:22 UTC 2025
> 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.
Evgeny Astigeevich has updated the pull request incrementally with one additional commit since the last revision:
Add missing include runtime/synchronizer.hpp
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/26863/files
- new: https://git.openjdk.org/jdk/pull/26863/files/4882b2db..d6895181
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=26863&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=26863&range=00-01
Stats: 1 line in 1 file changed: 1 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/26863.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/26863/head:pull/26863
PR: https://git.openjdk.org/jdk/pull/26863
More information about the hotspot-dev
mailing list