RFR: 8277342: vmTestbase/nsk/stress/strace/strace004.java fails with SIGSEGV in InstanceKlass::jni_id_for

David Holmes dholmes at openjdk.java.net
Fri Nov 19 02:05:42 UTC 2021


On Thu, 18 Nov 2021 21:56:58 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

> Use the version jni_id_for_impl() as jni_id_for() that takes out the JFieldIdCreation_lock before reading jni_ids in InstanceKlass.
> Tested with mach5 tier1-3.

Hi Coleen,

The changes in themselves seem fine. My only concern is whether always locking will introduce contention and impact performance. The code was attempting the classic pattern of doing a lock-free query first, but as you note it lacks the necessary memory ordering operations. So if needed we could make the lock-free path work correctly.

Thanks,
David

src/hotspot/share/oops/instanceKlass.cpp line 2064:

> 2062: }
> 2063: 
> 2064: /* jni_id_forfor jfieldIds only */

space needed between for's :)

src/hotspot/share/oops/instanceKlass.cpp line 2067:

> 2065: JNIid* InstanceKlass::jni_id_for(int offset) {
> 2066:   MutexLocker ml(JfieldIdCreation_lock);
> 2067:   // Retry lookup after we got the lock

The comment doesn't make sense now as there is only one lookup.

-------------

Marked as reviewed by dholmes (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/6466


More information about the hotspot-dev mailing list