RFR: 8330027: Identity hashes of archived objects must be based on a reproducible random seed [v3]
Thomas Stuefe
stuefe at openjdk.org
Tue Apr 23 05:48:28 UTC 2024
On Mon, 22 Apr 2024 05:24:55 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
> > > I get that the chance for this happening is remote, but hunting sources of entropy is frustrating work, and the patch is really very simple. So, why not fix it? I don't share the opinion that this is added complexity.
> >
> >
> > Why not do it inside `Thread::Thread()`
> > ```
> > // thread-specific hashCode stream generator state - Marsaglia shift-xor form
> > if (CDSConfig::is_dumping_static_archive()) {
> > _hashStateX = 0;
> > } else {
> > _hashStateX = os::random();
> > }
> > ```
>
> Because then it would inject `os::random` into the startup of every thread, not just of every thread that generates iHashes. So it would also fire for GC threads and other thread started before "our" threads. That would make our random sequence against order and number of threads started.
My last answer was rubbish, sorry, did not read your comment carefully enough.
Yes, your approach would also work, but it would lead to the two threads involved in dumping the archive - VMthread and the one Java thread - using the same seed, hence generating the same sequence of ihashes. That, in turn, can lead to different archived objects carrying the same ihash, which may negatively impact performance later when the archive is used.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/18735#issuecomment-2071456485
More information about the hotspot-runtime-dev
mailing list