RFR: 8338379: Accesses to class init state should be properly synchronized [v2]
Aleksey Shipilev
shade at openjdk.org
Fri Sep 27 19:11:35 UTC 2024
On Fri, 27 Sep 2024 18:59:36 GMT, Martin Doerr <mdoerr at openjdk.org> wrote:
> Nevertheless, the aforementioned `membar_storestore()` follows the allocation immediately and it includes an acquire barrier for the current thread, too.
OK, I see what you are getting at. But isn't that barrier still too late? See:
Thread 1 (in "new A()"):
<runtime check fires>
<clinit runs>
IK::init_state = fully_initialized
[stalls]
Thread 2: (also in "new A()"):
<runtime check passes: IK::init_state == fully_initialized>
<allocates>
membar_storestore(); // <---- nothing to cumulate with yet
<constructor runs> // not seeing <clinit> result fully, no barriers!
Thread 1:
[resumes]
<allocates>
membar_storestore(); // <---- too late!
-------------
PR Comment: https://git.openjdk.org/jdk/pull/21110#issuecomment-2379895063
More information about the hotspot-dev
mailing list