RFR: 8316397: StackTrace/Suspended/GetStackTraceSuspendedStressTest.java failed with: SingleStep event is NOT expected [v4]

Serguei Spitsyn sspitsyn at openjdk.org
Wed Feb 26 17:06:54 UTC 2025


On Wed, 26 Feb 2025 02:50:32 GMT, David Holmes <dholmes at openjdk.org> wrote:

>>> Does that mean we need the suspension check (and suspend) at other locations?
>>>
>> Yes, basically before posting any event. That’s why Serguei moved the check to `JvmtiExport::get_jvmti_thread_state()` to cover other events too. But I agree this method should not have side-effects. Also I don't see it is used for all events. I think we should probably use a new method.
>> 
>>> I am looking at JRT_ENTRY and it uses ThreadInVMfromJava - so why are we not checking for suspension in that transition somewhere, or else somewhere directly in the JRT_ENTRY? I guess maybe not all JRT_ENTRY points are safe for suspension? But then how do we know all the callers of get_jvmti_thread_state are safe for suspension?
>>>
>> We are checking for suspension in ~ThreadInVMfromJava(), the problem is that the check there is too late, and we have already posted the event. The fix aims to prevent the case where we suspend a thread, then we enable an event, and then the suspended thread posts that new enabled event without being resumed.
>
>> We are checking for suspension in ~ThreadInVMfromJava(), the problem is that the check there is too late,
> 
> Okay but why are we not checking in the initial transition from Java, or elsewhere in the JRT_ENTRY?
> 
> It just seems to me this is a general problem but we only happened to have tripped over one case of it.

David and Patricio, thank you for raising this concern and discussion. I agree that normal mechanisms like `JRT_ENTRY` or `ThreadInVMfromJava` should provide suspend points before posting the JVMTI events. Let me do some investigation/analysis first. I suspect we might need to provide a suspend point in the `ThreadInVMfromJava` constructor additionally to the one in the destructor even though it looks a little bit strange.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23490#discussion_r1971994711


More information about the hotspot-runtime-dev mailing list