RFR: 8350649: Class unloading accesses/resurrects dead Java mirror after JDK-8346567 [v4]
Coleen Phillimore
coleenp at openjdk.org
Tue Feb 25 20:17:51 UTC 2025
On Tue, 25 Feb 2025 20:14:23 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
>> See bug for description of the bug. Shenandoah seems to be the only GC that runs into this problem so far.
>>
>> Before [JDK-8346567](https://bugs.openjdk.org/browse/JDK-8346567), we pulled class modifiers from the native `Klass*`, and so we bypassed this trouble. But now we take modifiers out of Java mirror, and this happens during unloading, which accesses/resurrects potentially dead mirror.
>>
>> I think the solution is to keep storing a cached modifiers field in `Klass` instead of relying on Java mirror being accessible. Unfortunately, this patch undoes the removal of `u2` field from `Klass` done in [JDK-8346567](https://bugs.openjdk.org/browse/JDK-8346567).
>>
>> Additional testing:
>> - [x] Linux x86_64 server fastdebug, original reproducer now passes
>> - [x] Linux x86_64 server fastdebug, `hotspot_gc_shenandoah`
>> - [x] Linux x86_64 server fastdebug, `jdk_jfr`
>> - [x] Linux x86_64 server fastdebug, `jdk_jfr` with `-XX:+UseShenandoahGC` now passes
>
> Aleksey Shipilev has updated the pull request incrementally with one additional commit since the last revision:
>
> More comment polishing, getting too late here for doing this without three commits in the row
Yes, this looks good. computer_modifier_flags() should get the same answer whenever it's called. Your comment looks good. JFR do_write_class during unloading is something that's been tricky in the past, but I hope there is nothing else that accesses the mirror when it's dead and the class should be unloaded.
Was there a reproducer that can be added with this change? I assume ZGC could have the same sort of problem.
-------------
Marked as reviewed by coleenp (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/23775#pullrequestreview-2642359731
More information about the hotspot-dev
mailing list