Summary
Change the JVM TI spec of the GetLocalXXX/SetLocalXXX functions to require the target thread to be either suspended or the current thread. Also, specify that the error code JVMTI_ERROR_THREAD_NOT_SUSPENDED has to be returned if this requirement is not satisfied.
Problem
The following JVM TI functions are listed in the section "Local Variable":
GetLocalObject, GetLocalInt, GetLocalLong, GetLocalFloat, GetLocalDouble, GetLocalInstance,
SetLocalObject, SetLocalInt, SetLocalLong, SetLocalFloat, SetLocalDouble
All the functions above have a stack depth parameter for target frame identification. However, this stack depth of the target thread is transient and can change to the moment when a function gets access to the target stack frame.
Solution
The target thread must be suspended or the current thread to guarantee that the stack depth argument remains valid.
Specification
The spec of each JVM TI function in the list above should have the following two changes:
New statement at the end of function description:
The specified thread must be suspended or must be the current thread.
One more error code to the list of errors that the function can return:
JVMTI_ERROR_THREAD_NOT_SUSPENDED | Thread was not suspended and was not the current thread.
Each function spec in the jvmti.xml will have a diff like below:
@@ -5831,6 +5831,8 @@ class C2 extends C1 implements I2 {
<description>
This function can be used to retrieve the value of a local
variable whose type is <code>Object</code> or a subclass of <code>Object</code>.
+ <p/>
+ The specified thread must be suspended or must be the current thread.
</description>
<origin>jvmdi</origin>
<capabilities> @@ -5873,6 +5875,9 @@ class C2 extends C1 implements I2 {
<error id="JVMTI_ERROR_OPAQUE_FRAME">
Not a visible frame
</error>
+ <error id="JVMTI_ERROR_THREAD_NOT_SUSPENDED">
+ Thread was not suspended and was not the current thread.
+ </error>
</errors>
</function>
A Release Note will need to be created.
- csr of
-
JDK-8288387 GetLocalXXX/SetLocalXXX spec should require suspending target thread
- Resolved