Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8294690

GetLocalXXX/SetLocalXXX spec should require suspending target thread

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P3
    • 20
    • hotspot
    • None
    • behavioral
    • low
    • Hide
      Compatibility risk is low.
      The JVM TI GetLocalXXX/SetLocalXXX functions are for debuggers and unlikely to be used by other types of agents.
      The JDK's JDWP agent already suspends the target threads before calling the GetLocalXXX/SetLocalXXX functions where it is needed. If there are other JVMTI agents using these API's then they will need to change them to suspend the target thread, something that will work with older releases in the event that they want to support a wide range of JDK releases.
      Show
      Compatibility risk is low. The JVM TI GetLocalXXX/SetLocalXXX functions are for debuggers and unlikely to be used by other types of agents. The JDK's JDWP agent already suspends the target threads before calling the GetLocalXXX/SetLocalXXX functions where it is needed. If there are other JVMTI agents using these API's then they will need to change them to suspend the target thread, something that will work with older releases in the event that they want to support a wide range of JDK releases.
    • Other
    • SE

    Description

      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:

      1. New statement at the end of function description:

        The specified thread must be suspended or must be the current thread.
      2. 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.

      Attachments

        Issue Links

          Activity

            People

              sspitsyn Serguei Spitsyn
              sspitsyn Serguei Spitsyn
              Alan Bateman, Daniel Daugherty, Leonid Mesnik
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: