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

JDI: StackFrame.getArgumentValues causes JDWP error 32 (INVALID_SLOT)

XMLWordPrintable

    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.8.0_05"
      Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows 7, Microsoft Windows [Version 6.1.7601]
      and linux (version unknown)

      A DESCRIPTION OF THE PROBLEM :
      I am having several problems with com.sun.jdi.StackFrame.getArgumentValues() when I use it in conjunction with lambdas.

      The easiest-to-replicate error I have caused is the following. Use the example com.sun.tools.example.trace that comes with Java -- it has 3 files. One of them is EventThread.java; change it as follows:

         // Forward event for thread specific processing
          private void methodEntryEvent(MethodEntryEvent event) {
               // new :
               try {
                   if (event.thread().isSuspended()) {
                       List<StackFrame> frames = event.thread().frames();
                       if (frames.size() > 0)
                           frames.get(0).getArgumentValues();
                   }
               } catch (IncompatibleThreadStateException | InvalidStackFrameException e) {
                   System.err.println(e);
               }
               // old :
               threadTrace(event.thread()).methodEntryEvent(event);
          }

      Create and compile this separate file:

      import java.util.function.Function;
      public class FuncExample {
          public static void main(String[] args) {
              Function<Integer, Integer> f = x->x+1;
          }
      }

      Finally, run

      java com.sun.tools.example.trace.Trace FuncExample

      This causes:

      Exception in thread "event-handler" com.sun.jdi.InternalException: Unexpected JDWP Error: 32
              at com.sun.tools.jdi.JDWPException.toJDIException(JDWPException.java:65)
              at com.sun.tools.jdi.StackFrameImpl.getArgumentValues(StackFrameImpl.java:358)
              at com.sun.tools.example.trace.EventThread.methodEntryEvent(EventThread.java:297)
              at com.sun.tools.example.trace.EventThread.handleEvent(EventThread.java:239)
              at com.sun.tools.example.trace.EventThread.run(EventThread.java:84)

      However, adding the superfluous call to getArgumentValues() and the surrounding code should not have caused any additional output or errors.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See "Description"

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      See "Description"
      ACTUAL -
      See "Description"

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      See "Description"

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      See "Description"
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None known. In debugging situations it is extra problematic because when parameters are not named, this is only way to debug them.

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: