RFR: 8330027: Identity hashes of archived objects must be based on a reproducible random seed [v5]
Ioi Lam
iklam at openjdk.org
Sun May 5 05:01:58 UTC 2024
On Fri, 3 May 2024 07:54:40 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> src/hotspot/share/runtime/synchronizer.cpp line 952:
>>
>>> 950: if (t == nullptr) {
>>> 951: Atomic::cmpxchg(&cds_dump_java_thread, t, cur);
>>> 952: return true;
>>
>> I think this is not thread safe, as I got few intermittent asserts.
>
> Hmm, it should not really need to be thread safe, since it should only ever be called from a single thread. Do the asserts always happen in the one and only java thread?
I found the problem. A new `JavaThread` is created during VM exit. This thread is attached to the main OS thread:
Thread 2 "java" hit Breakpoint 3, JavaThread::JavaThread (this=0x7ffff002c4e0, is_attaching_via_jni=true) at javaThread.cpp:532
532 JavaThread::JavaThread(bool is_attaching_via_jni) : JavaThread() {
(gdb) where
#0 JavaThread::JavaThread (this=0x7ffff002c4e0, is_attaching_via_jni=true)
#1 attach_current_thread (vm=0x7ffff7c283d8 <main_vm>, penv=0x7ffff5358d50, _args=0x7ffff5358d60, daemon=false)
#2 jni_AttachCurrentThread (vm=0x7ffff7c283d8 <main_vm>, penv=0x7ffff5358d50, _args=0x7ffff5358d60)
#3 JavaVM_::AttachCurrentThread (this=0x7ffff7c283d8 <main_vm>, penv=0x7ffff5358d50, args=0x7ffff5358d60)
#4 jni_DestroyJavaVM_inner (vm=0x7ffff7c283d8 <main_vm>)
#5 jni_DestroyJavaVM (vm=0x7ffff7c283d8 <main_vm>)
#6 JavaMain ()
#7 ThreadJavaMain ()
#8 start_thread (arg=<optimized out>)
#9 clone3 ()
This thread can execute Java code (shutdown hooks) which can call `Object::identityHashcode()`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18735#discussion_r1590208765
More information about the hotspot-runtime-dev
mailing list