RFR: 8338379: Accesses to class init state should be properly synchronized [v3]
Aleksey Shipilev
shade at openjdk.org
Mon Sep 30 17:11:57 UTC 2024
> See the bug for the discussion. We have not seen a clear evidence this is _the_ problem in the field, neither we were able to come up with a reproducer. We have found this gap by inspecting the code, while chasing a production bug.
>
> In short, `InstanceKlass::_init_state` is used as the "witness" for initialized class state. When class initialization completes, it needs to publish the class state by writing `_init_state = _fully_initialized` with release semantics.
>
> Various accessors that poll `IK::_init_state`, looking for class initialization to complete, need to read the field with acquire semantics. This is where the change fans out, touching VM, interpreter and compiler paths that e.g. implement clinit barriers. In some cases in assembler code, we can rely on hardware memory model to do what we need (i.e. acquire barriers/fences are nops).
>
> I made the best _guess_ what ARM32, S390X, PPC64, RISC-V code should look like, based on what related code does for volatile loads. It would be good if port maintainers could sanity-check those.
>
> Additional testing:
> - [x] Linux x86_64 server fastdebug, `all`
> - [x] Linux AArch64 server fastdebug, `all`
> - [x] GHA to test platform buildability + adhoc platform cross-compilation
Aleksey Shipilev has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
- Merge branch 'master' into JDK-8338379-class-init-checks
- Pick up PPC64 patch from Martin
- Relax to just a release
- Initial version
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/21110/files
- new: https://git.openjdk.org/jdk/pull/21110/files/179d8aa1..a7895d94
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=21110&range=02
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=21110&range=01-02
Stats: 20318 lines in 465 files changed: 14509 ins; 3375 del; 2434 mod
Patch: https://git.openjdk.org/jdk/pull/21110.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/21110/head:pull/21110
PR: https://git.openjdk.org/jdk/pull/21110
More information about the hotspot-dev
mailing list