Question on JavaThread::is_ext_suspend_completed()

Reingruber, Richard richard.reingruber at sap.com
Wed Sep 16 21:05:32 UTC 2020


Hi,

I've got a question on JavaThread::is_ext_suspend_completed():

Current thread C loads the thread state of target thread T [1]. Assume it
observes _thread_in_native and also that T has a walkable stack. In this case
is_ext_suspend_completed() returns true [2]. If called by JavaThread::java_suspend(), then this
method will also return.

I don't see the synchronization that shields against C seeing stale values of T's
thread state and frame anchor. To me it looks as if T could be executing java
bytecodes while C observes a stale state making the wrong conclusion that T
is effectively suspended.

What am I missing?

I'd think that a sleep just before returning true could trigger the issue, can't it? [4]

Thanks, Richard.

[1] Loading thread state
    https://github.com/openjdk/jdk/blob/1c84cfa2364fa18fc028df89bdc4de207365784f/src/hotspot/share/runtime/thread.cpp#L671

[2] JavaThread::is_ext_suspend_completed() Returns true if save_state == _thread_in_native && frame_anchor()->walkable()
    https://github.com/openjdk/jdk/blob/1c84cfa2364fa18fc028df89bdc4de207365784f/src/hotspot/share/runtime/thread.cpp#L686

[3] JavaThread::java_suspend() returns if JavaThread::is_ext_suspend_completed() returns true.
    https://github.com/openjdk/jdk/blob/1c84cfa2364fa18fc028df89bdc4de207365784f/src/hotspot/share/runtime/thread.cpp#L2512

[4] Can a sleep before returning (see link below) trigger the issue?
    https://github.com/openjdk/jdk/blob/1c84cfa2364fa18fc028df89bdc4de207365784f/src/hotspot/share/runtime/thread.cpp#L691


More information about the hotspot-runtime-dev mailing list