RFR: 8224852: JVM crash on watched field access from native code [v3]

Leonid Mesnik lmesnik at openjdk.org
Wed Oct 22 03:40:06 UTC 2025


On Tue, 21 Oct 2025 23:15:38 GMT, Serguei Spitsyn <sspitsyn at openjdk.org> wrote:

>> Leonid Mesnik has updated the pull request incrementally with three additional commits since the last revision:
>> 
>>  - completed renaming
>>  - renamed test
>>  - updated after feedback
>
> src/hotspot/share/prims/jvmtiExport.cpp line 2283:
> 
>> 2281:   // In this case the frame is only marked for deoptimization but still remains compiled.
>> 2282:   // Also, the last frame might be compiled if events were not enabled for
>> 2283:   // this thread. The thread filtering is done later.
> 
> Q: The following part of comment is confusing: `" ... if events were not enabled for this thread."
>      How do we post the events if they were not enabled? Do I miss anything?

Yes
The
jni_GetField_probe
is called on every field if any of fields access event is envabled.

  /* Keep JVMTI addition small and only check enabled flag here.       */ \
  if (JvmtiExport::should_post_field_access()) { \
    o = JvmtiExport::jni_GetField_probe(thread, obj, o, k, fieldID, false); \
  } \

The jni_GetField_probe checks if the events are enabled for this specific field on any thread for any jvmtiEnv and call

post_field_access_by_jni

which prepare all the data and call 

post_field_access

Only on this level it is check which threads and environments should post events. I suspect that it is done for unification of jni/non-jni check.

 So ```post_field_access_by_jni```  is executed for threads where events is not enabled.

> test/hotspot/jtreg/serviceability/jvmti/events/FieldAccess/FieldsEventsFromJNI/FieldsEventsFromJNI.java line 30:
> 
>> (failed to retrieve contents of file, check the PR for context)
> Nit: The class name still does not match the test folder name: `s/FieldsEventsFromJNI/FieldEventsFromJNI/g`

Thanks, missed 's'.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27584#discussion_r2450316108
PR Review Comment: https://git.openjdk.org/jdk/pull/27584#discussion_r2450317813


More information about the serviceability-dev mailing list