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

JVMTI spec incorrectly states that PopFrame cannot be called on the current thread

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 13
    • hotspot
    • None
    • behavioral
    • minimal
    • Hide
      The risk of this update is minimal.
      It removes the limitation to not execute PopFrame on the current thread.
      Also, the spec is fixed to reflect the current implementation.
      So, nothing is going to be broken for customers.
      Show
      The risk of this update is minimal. It removes the limitation to not execute PopFrame on the current thread. Also, the spec is fixed to reflect the current implementation. So, nothing is going to be broken for customers.
    • Other

      Summary

      The JVMTI PopFrame spec must be aligned with the implementation.

      The spec should allow PopFrame to be called on the current thread.

      Problem

      The problem is that the PopFrame spec is not aligned with the implementation which allows the PopFrame to be called on the current thread. Also, it has to be in sync with the ForceEarlyReturn spec which allows the ForceEarlyReturn to be called on the current thread.

      Solution

      Two spots in the PopFrame spec have to be updated.

      #1: General description:

      "The specified thread must be suspended (which implies it cannot be the current thread). "

      Instead, it should state:

      "The specified thread must be suspended or must be the current thread."

      #2: The PopFrame JVMTI_ERROR_THREAD_NOT_SUSPENDED error code description states:

      "Thread was not suspended."

      Instead, it should state:

      "Thread was not the current thread and was not suspended."

      Specification

      Here is the patch below:

      diff -r b6418e5aad70 src/hotspot/share/prims/jvmti.xml
      --- a/src/hotspot/share/prims/jvmti.xml Thu May 30 15:55:16 2019 -0700
      +++ b/src/hotspot/share/prims/jvmti.xml Fri May 31 15:43:06 2019 -0700
      @@ -2824,7 +2824,7 @@
          <p/>
          Changes to global state are not addressed and thus remain changed.
          <p/>
      -   The specified thread must be suspended (which implies it cannot be the current thread).
      +   The specified thread must be suspended or must be the current thread.
          <p/>
          Both the called method and calling method must be non-native Java programming
               language methods.
      @@ -2849,7 +2849,7 @@
                 The implementation is unable to pop this frame.
          </error>
          <error id="JVMTI_ERROR_THREAD_NOT_SUSPENDED">
      -     Thread was not suspended.
      +     Thread was not the current thread and was not suspended.
          </error>
          <error id="JVMTI_ERROR_NO_MORE_FRAMES">
            There are less than two stack frames on the call stack.
      @@ -2937,7 +2937,7 @@
                 native method.
          </error>
          <error id="JVMTI_ERROR_THREAD_NOT_SUSPENDED">
      -     Thread was not suspended and was not the current thread.
      +     Thread was not the current thread and was not suspended.
          </error>
             </errors>
           </function>

      The webrev is:

      http://cr.openjdk.java.net/~sspitsyn/webrevs/2019/8205126-jvmti-spec-popframe.1/

      The specdiff is:

      http://cr.openjdk.java.net/~sspitsyn/webrevs/2019/8205126-jvmti-spec-popframe.1/jvmti-specdiff/

            sspitsyn Serguei Spitsyn
            cjplummer Chris Plummer
            Daniel Daugherty
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: