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

JVMTI is not properly hiding some continuation related methods

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3 P3
    • 24
    • 24
    • hotspot
    • In Review

      Continuation.yield0() is showing up in the stack traces. It is not suppose to since it is a method that is suppose to be hidden. The method is being included in GetStackTrace, and also GetFrameCount.

      The following simple test case and jdb session demonstrate the issue. Note the reason for setting the breakpoint is so jdb learns about the Virtual thread. Otherwise it won't show up in the threads list.

      Main {
          public static void main(String[] args) throws Exception {
              Thread thread = Thread.ofVirtual().unstarted(Main::test);
              System.out.println(thread);
              thread.start();
              thread.join();
          }
          
          static void test() {
              try {
                  Thread.sleep(1000000);
              } catch (InterruptedException e) {
              }
          }
      }

      $ jdb Main
      Initializing jdb ...
      > stop at Main:11
      Deferring breakpoint Main:11.
      It will be set after the class is loaded.
      > run
      run Main
      Set uncaught java.lang.Throwable
      Set deferred uncaught java.lang.Throwable
      >
      VM Started: Set deferred breakpoint Main:13
      VirtualThread[#34]/new

      Breakpoint hit: "thread=", Main.test(), line=13 bci=0
      13 Thread.sleep(1000000);

      [1] cont
      > suspend
      All threads suspended.
      > threads
      Group system:
        (java.lang.ref.Reference$ReferenceHandler)406 Reference Handler running
        (java.lang.ref.Finalizer$FinalizerThread)407 Finalizer cond. waiting
        (java.lang.Thread)408 Signal Dispatcher running
        (java.lang.Thread)405 Notification Thread running
      Group main:
        (java.lang.Thread)1 main cond. waiting
      Group InnocuousThreadGroup:
        (jdk.internal.misc.InnocuousThread)432 Common-Cleaner cond. waiting
        (jdk.internal.misc.InnocuousThread)762 VirtualThread-unparker cond. waiting
      Group CarrierThreads:
        (jdk.internal.misc.CarrierThread)755 ForkJoinPool-1-worker-1 cond. waiting
      Group VirtualThreads:
        (java.lang.VirtualThread)759 cond. waiting
      > where 759
        [1] jdk.internal.vm.Continuation.yield0 (Continuation.java:360)
        [2] jdk.internal.vm.Continuation.yield (Continuation.java:351)
        [3] java.lang.VirtualThread.yieldContinuation (VirtualThread.java:526)
        [4] java.lang.VirtualThread.parkNanos (VirtualThread.java:716)
        [5] java.lang.VirtualThread.sleepNanos (VirtualThread.java:888)
        [6] java.lang.Thread.sleepNanos (Thread.java:495)
        [7] java.lang.Thread.sleep (Thread.java:528)
        [8] Main.test (Main.java:13)
        [9] Main$$Lambda/0x00007f0fdb000a18.run (null)
        [10] java.lang.Thread.runWith (Thread.java:1,589)
        [11] java.lang.VirtualThread.run (VirtualThread.java:404)
        [12] java.lang.VirtualThread$VThreadContinuation$1.run (VirtualThread.java:217)
        [13] jdk.internal.vm.Continuation.enter0 (Continuation.java:320)
        [14] jdk.internal.vm.Continuation.enter (Continuation.java:312)

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

              Created:
              Updated: